3dgodotgodot4

Godot 4 3d Gdscript get object collided with


How do I get the name of an object I have collided with or see if I have collided? I want to have an object that changes a variable when touched by the player.

I have set up the group layers and masks but don't know which function to use to see if the object has collided


Solution

  • Rigidbodies and Area CollisionObjects will emit the body_entered signal whenever a body enters (or collides with) them. You can connect a callable to that.

    The signal has the collision node as a parameter, so you can access it's name or whatever properties interest you.