0 votes

I have a Rigidbody2D that is shot towards a KinematicBody2D using apply_impulse(Vector2(0,0),-get_global_transform().y*SPEED)
, the Kinematicbody2D has a script that contains:
if is_colliding(): print("Collision Detected") Rigidbody.queue_free()
When it collides for some reason it doesn't detect the collision. How do I fix it?
Thanks in advance.

in Engine by (18 points)

for what i got to understand with the Rigidbody2D if doesn't really collide but uses a (assuming) lot of code to redirect the collision thus creating the feeling of bouncing on a wall or simply stopping, yet not colliding

1 Answer

0 votes
Best answer

Kinematic bodies normally do not detect collisions (here and in other engines), collision detection is only triggered by the move api, if you need to use is_colliding, use move first.

If the kinematic body won't move you can use the rigid body to pass the collision with a signal using body_enter (enable monitoring and increase the contact number for this to work).
So in the rigid's body enter, check the body parameter, if is the kinematic body you want (group or class check) use a function on the kinematic script to do something with that information.

Other option is to connect the rigid to the kinematic directly but the usefulness of that depends on the design.

And in some cases you can just add an area to the body to detect others.

by (7,888 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.