Rigidbody (player) moves slower on moving platform
I'm trying to make my rigidbody player move on a platform and I cannot figure it out. There were a few questions already about it but none of the answers seemed to work for me.
If I put a rigidbody on the platform, make it kinematic and move it using MovePosition, the player bounces up and down when the platform moves up/down and falls off the platform when it moves right/left. If I take the rigidbody off the platform, move its transform and set the player to be a child of the platform, the player sticks to the platform as it should but left and right movement is slow and jittery.
I have a deadline that I need to meet very soon on this and I'm getting a bit worried, any ideas?
Answer by carrytheswordgamestudio · May 26, 2021 at 03:13 AM
how it was solved for me. I am just implementing moving platforms in my game now and discovered the same issue. My problem was the rigidbody2d interpolation. while on the platform try changing the interpolation to none, then if you are using interpolation or extrapolation, just switch it back when you get off of the platform... rigidbody2D.interpolation = RigidbodyInterpolation2D.None. Also the player has to be parented to the moving platform while on it. Hope this helps.
Answer by IAmChiagozie · Sep 11, 2020 at 10:25 AM
This answer is a little over a year old, but I had a somewhat similar problem as this.
In my project, the player moves with animator root motion while the platform moves with an animation instead.
I made my platform's script to let the platform become the parent of any object that is on it and set that object's parent to null if it ever leaves the platform. Now, the problem arises when my player jumps onto the platform, he's speed is suddenly slow.
In order to fix this, I had to go into the player's script and create a boolean value that checks if he is on a moving platform or not, now if he is, use rigidbody.velocity movement with a greater speed, then if he isn't, use the default animator root motion instead.
I hope this gives you an idea on how to fix this if you encounter the same problem.
PS: If you have jitters while on the platform, you should put your camera follow codes in LateUpdate(). If you use Cinemachine, set the X and Y damping to 0.
CHEERS!