Rotating platform

Hello everyone.

I’m creating a platform game, and in a certain point of the level I want the character to be able to run over a rotating plataform (Like the ones in super mario sunshine, for example). I’ve created a cube with the unity editor, attached a rigidbody to it (the box collider is also attached) and made it rotate with this script:

function FixedUpdate () {
var deltaRotation : Quaternion = Quaternion.Euler(Vector3(0,0,5) * Time.deltaTime);
rigidbody.MoveRotation(rigidbody.rotation * deltaRotation);
}

My main character has a characterController component attached and moves using the characterController.Move function like in many examples on the net.

The problem is that when the platform is rotating, if you’re standing still, when a certain point in the rotation is achieved (a little after it has completed a whole rotation, and the platform is horizontally placed) the character Controller collider simply trespasses the box collider and my character fells, trespassing the whole platform.

Does anyone know why this is happening? Should I use another code to rotate the platform? I think this has something to do with the physics engine and collision detection.

Any help would be appreciated.

Ich have the problem too. I want to jump on the platform, the platform is rotating, but if i parent the player to that object, it also gets the same rotation. This is very confusing. The player should stay with his own rotation he first had when he entered the platform... Someone can help with that problem here?

–

1 Answer

1

It sounds like parenting the player with the moving platform could be an idea.

This guy teaches how to parent. (I learned from him)

Transform.parent docs

Quite simple solution, but it should work really great.

Well, I've tried to do the same as in the video, but it seems I haven't been able to do it though. When I parent my character's transform to the platform's transform, my character not only moves along with the rotating platform, but scales and rotates also with it, so I am not really able to tell wether this sollution works right or not but it definitely isn't working right now. Did I miss something? I tried to do the same as in the video. And, will this work with a rotating platform also? In the video it was just a simple moving elevator.

–