I don't know why, but the StompDetector works for me with Godot 3.2.1 only sometimes, but mostly not. There is also no error message when it does not work.
func _on_StompDetector_body_entered(body: Node) -> void: if body.global_position.y > get_node("StompDetector").global_position.y: return get_node("CollisionShape2D").disabled = true queue_free()
It's most likely due to the position and size of the colliders. It's a bit finicky to get them to work well.
You said there was an error message when it doesn't work. Could you share it with me? You should have a copy button in Godot's output console to copy it.
Unfortunately there is no error message.
I see, the issue you faced had to do with two things:
1. In the project you sent me, the StompDetector was not connected to the Enemy node.
2. The collisions code wouldn't detect the enemy due to the StompDetector's position.
This is what I mentioned in the first reply, and it's due to these lines of code:
func _on_StompDetector_body_entered(body: Node) -> void: if body.global_position.y > get_node("StompDetector").global_position.y: return
Your setup might look like mine, but it's not exactly like mine. In your demo, by the time the collision gets registered with the StompDetector, the player is 1 pixel lower than the StompDetector node, causing the function to return early.
To solve this, you need to move down the StompDetector node a bit, and move the CollisionShape2D up a bit.
I'm currently busy moving house but I'll look into adding a more reliable solution for that stomp in a course update. I have to experiment to find a beginner-friendly setup that works well. We had a more complex setup that worked reliably, but it was not beginner-friendly anymore.
I hope this helps fix your issue!
In the archive I downloaded, the signal was disconnected for some reason. Don't worry about it if the signal is connected on your end.
Great! Moving the StompDetector node down a bit and moving the CollisionShape2D up a bit solved the problem without changing anything on the connection of the signal.
Many thanks. That is very nice.
I was debugging it now also and I was 1 pixel away all the time - you can try to add something like 5px margin if you got problems
export var STOMPMARGIN: = 5.0 if body.global_position.y > $StompDetector.global_position.y + STOMPMARGIN: