#Do an action upon being collided with

1 messages · Page 1 of 1 (latest)

rustic furnace
#

I have a node which I want to delete itself when a projectile bounces off of it. For the bouncing, I have a CollisionShape2D. However, when I also play an Area2D in order to detect an interaction to delete the node, this doesn't work, because the Area2D doesn't have time to register the intersection before the collision happens. And I can't simply make the Area2D collider larger because then there are cases where the bouncing doesn't happen. move_and_collide() doesn't seem to be working because this object doesn't move. One possible hack is to create a very short timer (maybe 0.1s) before deleting the node, but I'd prefer to do things right. It seems strange to me that there's no straightforward way to detect whether a node is being collided with, and I imagine I'm missing something.

Update: The combination of making the Area2D collider larger and adding a timer doesn't work for the reason that it still picks up the intersection even if the node doesn't get hit. And if I make the collider small enough for this to not be a problem, the intersection is sometimes missed.

rustic furnace
#

ok i came up with a solution. i have it on the script of the projectile, which collides with this one, to destroy it on collision