RigidBody2D interaction with moving KinematicBody2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Lucca

I made this question earlier in the godot discord but I didn’t get much further, might as well see if someone can help me here. Let me know if I need to clarify anything further or post some code.

I’m using RigidBody2d character mode for my player and I’m facing some barriers. Being more specific I want to have moving platforms in my game and friction doesn’t do a good job at “Linking” a moving KinematicBody2d to a RigidBody2d.

I would really like to keep the Rigidbody behaviors(gravity, damping, impulse, force) and have the ability to snap my player to the platform/add the same amount of speed as the platform (or any other solution you could help me think about). I spent the afternoon trying to figure this out but didn’t find anything that would help me with this so i tried Kinematicbody2D wich was not as good as i expected, it looks like I’ll have to do a lot of work to get close to what I have now and I don’t even know how I would go about coding those behaviors.

So the question is, should I stick to the RigidBody2d approach (If yes what should i do?) or should i consider a lost cause and go for reproducing those behaviors in a KinematicBody2d?

Even if you dont have an answer to this I would really appreciate an opinion about it.

I take you’ve already read about the move_and_slide_with_snap() function that comes with a KinematicBody2D?

Ertain | 2020-06-26 02:21

Yes! The main problem here is that if I try to apply the same speed to the RigidBody2D it doesn’t translate well since its another function that’s applying the force.

Lucca | 2020-06-26 02:40

:bust_in_silhouette: Reply From: LLJ

Can’t you detect a collision with the RigidBody2D see that it is a platform that you are colliding with. You know the speed of the platform so set RigidBody2D accordingly.

Sorry for the delayed response,
How would i do that if the platform movement and the player movement are being applied differently?

Lucca | 2020-07-18 16:39