How to get the player to rotate with a rotating platform?
So to get started, let's address to the two pictures.
One picture shows my scene with the player on a checkerboard base and next to him is a platform that is spinning (which I accomplished by simple keyframe animation in Unity). That platform is the one I will be referring to for the rest of this post.
The other picture shows my script that is attached to the platform. I've seen this script a few times in my search for help.
Note: I am using the most recent version of the Standard Assets pack you can import from the Asset Store for my first person player, which you can see in the Hierarchy on the left in the picture of my scene.
So, the script works and obviously whenever the player is not on the platform, he is not parented to it. But whenever he is on the platform, he is parented to it. So here's my first problem: The moment the player lands on the platform and collides with the trigger box (and thus is parented, because of the script), something strange happens to his rotation. The player's rotation just jerks to a different direction. The same thing happens when he jumps off the platform (and thus is no longer parented), his rotation jerks again to a different direction. It seems like when he jumps off the platform, the rotation he had before jumping onto the platform returns to him. But either way, if you were playing a game like this, you would expect the rotation of the player to stay the same when landing and jumping off of the platform. But this is not the case.
Here's my second problem: Whenever the player is on the platform, although his position and rotation is the same as the platform, he is sliding back and forth slightly for some reason. It's like there's a misalignment issue or something causing him to move around while on the platform.
What's sad is that a long time ago when I used an earlier version of Unity to make a parkour game, the Standard Assets came with some JavaScripts, and one of them (or maybe more than one of them) prevented these issues from happening. But because Unity no longer uses JavaScript, and no one has recreated this stuff exactly the same way in C+, I don't know what to do.
So please, the game I'm making has a lot of mechanics that involve jumping onto different types of platforms, and spinning platforms is one of them. It is absolutely vital that I can get this game mechanic to work. And please, I'm not a scripter, so please don't just only show a few scripting words or a variable name. I need someone who can create a whole script that fixes both of these issues. If you could post that full script, I would greatly appreciate it! And please explain in detail what I need to do. Thanks!
Note: And, yes... I know this question has been asked before, but I've had no luck looking at all those other posts so please don't direct me to them. This post needs to be fresh and provide an answer to not only me, but those who come after me, looking for answers and can find them on this post. Thanks.
Answer by InfernalMajesty89 · Nov 06, 2020 at 08:14 PM
i hope you've figured this out by now but Problem 1: Make sure your player's default transform identity is zeroed out. You can do that in script when they become parented but this might cause a blip on screen, better to do it before compiling.
Problem 2: Set rigidbody collision checking to continuous or continuous dynamic in the Inspector.
Your answer
![](https://koobas.hobune.stream/wayback/20220612203134im_/https://answers.unity.com/themes/thub/images/avi.jpg)