a rigidbody moving along with a moving platform

Hi everyone, I followed this video on how to move a 2D character using forces:

I’ve run into difficulties implementing moving platforms, I’ve tried setting the player’s velocity to that of the moving platform but this method has a lot of caveats to it and making the player a child of the moving platform is off the table since the player is a dynamic rigidbody.
The platform is a kinematic rigidbody with no physics materials attached to it, it’s being moved by directly setting its velocity every FixedUpdate call. I’ve also tried moving it using the method MovePosition but this results in having the rigidbody’s velocity being (0, 0) constantly.
I’m open to any suggestions you have, thank you in advance!

Then MovePosition and setting its velocity will have no effect and you must set the transform.position.

Check out the docs… I quote:

.isKinematic:

Description
Controls whether physics affects the rigidbody.

If isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody anymore. The rigidbody will be under full control of animation or script control by changing transform.position.

If you have a solution, i would be glad if you would share it with me, i have a similar thread here, searching for answers. I have also kind of a moving platform that is kinematic, when the player is on the platform i turn him also kinematic and child him to the platform etc… kind of works, but not really good.

also, what kurt-dekker posted was from “rigidbody” and not “rigidbody2d” documentation. so is it the same? because this text is not from the rigidbody2d.iskinematic documentation :slight_smile: and what if you have iskinematic and also “use full kinematic contacts” checked? …

Thanks for sharing that video, that’s an interesting approach for movement that I’m going to have to play around with. If you’ve implemented the movement code from the video, I would think you could just add the platforms velocity to the targetSpeed variable.

That’s exactly what I did, but the character slides around while standing still for some reason. It’s not the friction that’s causing it since I don’t apply if no input from the player is recieved

1 Like

I wonder if maybe it’s due to the acceleration and deceleration in the movement code. If the player is on a platform that’s moving at a constant velocity, you wouldn’t want to ramp up/down to match that speed, you’d want it to be instantaneous.

I am in this exact situation. I’m working on a game where my 2d character (moved with rigidbody and velocity) stays on a boat, which is a kinematic rigidbody. When he drives the boat, it is set to kinematic and fixed in driving position. When he stops driving, I want it to become able to walk inside the boat keeping the same inertial frame of reference of the boat. But as you also said, the character for some reasons “slides” faster or differently from the boat.
I saw a lot of videos talking about moving platforms, but all of them consider the platform NOT AS RIGIDBODY. I think that’s the problem, but I’d like to keep the kinematic rigidbody on my boat, because I don’ want to manage velocity and acceleration computing them by hand using transform…
Any advise about this?

1 Like