- Home /
How to always face player relative to player's rotation and how do I use TransformDirection to move a player regardless of Y-rotation?
So I have 2 questions. First problem:
I'm creating a planet object and the player can walk around. Obviously the rotation of the player changes depending on where the player is on the planet. My problem is I can't get the Camera to rotate to always face the player depending on where he is.
Yes, I've tried Quaternion.LookRotation, transform.LookAt, and all that jazz. The camera rotation should always be facing exactly down at the player, so if I was on a plane, the camera's rotation should be X: 90, Y: 0, Z: 0.
And the camera should always be facing the right forward direction, so I don't want to "turn" the camera...
My second problem:
I'm using the player's rigidbody to move it, here's the code:
playerRigidBody.MovePosition(transform.position + transform.TransformDirection(movement.x, 0f, movement.z) * speed * Time.deltaTime);
I'm using TransformDirection because I have to use local space to move it or it just goes straight on the global space. But I don't want it to move based on its facing direction. I want the player to move forward based on the Camera's orientation. How would I do this?
Thanks in advance!