Can't detect collision when using RigidBody2D for the Jump Pad

Hello folks, been struggling with this issue for a while. It seems like the simplest thing but for the life of me, I can’t get a RigidBody2D to detect a collision with my Player (KinematicBody2D).

I thought it would have been more realistic to use a Rigid Body since they Player wouldn’t walk right through it like they would walk right through an Area, but regardless of my Collision Layer/Mask settings, it will only detect collisions with the Terrain, but not the Player.

Is there something specific about Kinematic Bodies colliding with Rigid Bodies that I can’t find in the documentation?

I’m also going through a set of YouTube video’s from HeartBeast (Ben Anderson, aka uheartbeast on Discord) and he has a RigidBody2D colliding with a KinematicBody2D. In the RigidBody2D settings the ContactsReported needs to be set to a value of 1 or more and the Contact Monitor needs to be enabled.

Now if you have a script attached to the RigidBody2D node you can see if its working with this little bit of code:

func _physics_process(delta):
	var bodies = get_colliding_bodies()
	
	for body in bodies:
		print(body.name)

From my little bit of playing around with this it seems like collisions only occur with the StaticBody2D, RigidBody2D and KinematicBody2D nodes.

Hey @TyN, thanks for the response! I actually tried those settings and the collision still would not be reported. I did observe something weird though. If, for some reason, the RigidBody2D was moving, then the collision with the KinematicBody2D would be reported. So if I placed the RigidBody in the air and it fell on my Player object, I’d get a response. If it’s standing still though, nothing :frowning:

I knocked up a quick little test project with a Kinematic and Rigid body. When the Rigid hits the Kinematic I get a collision in the script that is attached to the Rigid: using get_colliding_bodies(). When the Kinematic hits the Rigid I get a collision in the script attached to the Kinematic: using get_slide_count() and get_slide_collision() though.

So I think for what you want to do you will need to use the get_slide_count() and get_slide_collision() functions from KinematicBody2D to know when you collide with a coin that is a RigidBody2D.

I tried using both signals and get_colliding_bodies and neither worked. I ended up having to use an Area2D as a child of the RigidBody2D to get the results I wanted. I will try again in a simpler setup and see if maybe something else was off.

So I made a new test project and I got the collision reported using the signal, still doesn’t work in my original project though. No idea why. If I put the rigid body in the sky and it falls on the player, I get a collision. If I put it on the ground and have the player run into it or jump on top of it, no collision. Weird but I’m happy to ignore it for now because the design I ended up with I think it better anyway :stuck_out_tongue:

Privacy & Terms