Search code examples
godot

Body entered function not working in godot


I am trying to make a node named "gear" change textures when it moves through a certain area, but nothing happens. I tried making it print something when it collides with something, but nothing happens; this problem has been bugging me for days, and I can't find any reason why; its hitbox is working, but the function refuses to acknowledge it

The capitalization is all right. I literally copied and pasted it to no avail. I looked at someone else's code other than the name of that node, and the function is the same; what is going on? link to the project


Solution

  • The problem is that you are trying to attach the body entered signal to a RigidBody2D which won't work.

    In order for a rigid body to report collisions, you must enable "Contact Monitoring" and set "Contacts Reported" to a value greater than 0.

    See [Solved] RigidBody2D body_entered signal does not work