Question by
ArtInACart · May 22, 2018 at 05:51 AM ·
rotationmovementphysicsmovement scriptmovements
Character Rotation
So I have this code to make the player look forward while moving along the vertical axis.
if (Input.GetAxis ("Vertical") > 0 | Input.GetAxis ("Vertical") < 0) {
Quaternion turnAngleFB = Quaternion.Euler(0, centerPoint.eulerAngles.y, 0);
character.rotation = Quaternion.Slerp(character.rotation, turnAngleFB, Time.deltaTime * rotationSpeed);
}
What I'm trying to do is achieve the same effect on the horizontal axis, where the front face of the player faces in the direction its moving along the horizontal axis. This is what I have so far, but I'm missing something and I'm almost certain its something super simple that I'm not getting...
if (Input.GetAxis("Horizontal") > 0 | Input.GetAxis("Horizontal") < 0) {
Quaternion turnAngleLR = Quaternion.Euler(0, centerPoint.eulerAngles.y, 0);
character.rotation = Quaternion.Slerp(character.rotation, turnAngleLR, Time.deltaTime * rotationSpeed);
}
Any help? Thanks in advance!
Comment
Your answer
Follow this Question
Related Questions
Fixed Update randomly stops player rotation 0 Answers
Arrow mechanic like soccer star 0 Answers
Jumping in my script deosnt work,How make this script to jump? 0 Answers
player movement not using rotation 0 Answers
Movement acceleration 1 Answer