Dynamic Rigidbody sitting on another dynamic rigidbody

Hi all,

I have been cracking my head over this. I am developing a 2D multiplayer game and the feature i want involves a Dynamic Rigidbody2D player sitting on top of another Dynamic Rigidbody2D player. When the player below moves, the player on top moves as well. At the same time, the player on top can move independently while keeping the velocity from the player are the bottom.

Any idea how I can implement this?

This sorta stuff can be pretty fiddly. The usual approaches involve things like:

  • disabling the physics on the second object while riding the first (while making it a child), then re-enabling physics if you fall or jump off

  • using a fixed joint of some kind to join the two rigidbodies when you are on it, then breaking that joint when you jump/fall off.

Either way, it’s not trivial to get it working right. There’s some tutorials on riding platforms out there, but you have to find one that actually simulates the platform with physics rather than just moving it.

There’s also a physics / physics2D forum on this board.