charactercontroller; move relative to camera, ignore parent

Hi,

Using the character controller, I make the character a child of the plaform that he’s on. When onTriggerExit, i make the parent null again.

But what happens…the platform rotates. This means that my controls also are being offsetted.

Pressing the right cursor doesn’t make the character go right in relation to the camera, because he’s on a rotating platform.

How can I ignore this? I would need to move the character in relation to the world, I guess? How do I do this?

Thanks!

http://www.stickystudios.com/files/test.html

Current code:

function FixedUpdate() {
    var controller : CharacterController = GetComponent(CharacterController);
    if (controller.isGrounded) {
        moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed; 
        if (Input.GetButton ("Jump")) {
            moveDirection.y = jumpSpeed;
        }
    }

    moveDirection.y -= gravity * Time.deltaTime;
    controller.Move(moveDirection * Time.deltaTime);
}

ps: I know the quaternion of the object I am standing on

GOT IT!

moveDirection = Camera.main.transform.TransformDirection(moveDirection);
Voila!!! :smile: :smile: :smile: :smile:

ahum. :roll:

i don’t know why but the movement for Y set it to 0 it just ignores gravity