- Home /
Character Rotation Question
Hi Guys;
I'm using the Third Person Controller.js script with minor tweaks here and there. I'm trying to utilitze an over the shoulder mode with the right mouse button, where I try to make the player character's rotation a slave to the camera's rotation, that way the character will always stay in a certain place according to the camera while retaining the third person movement abilities. I have come across a problem, where my simple script will cause the character model to rotate extremely fast across the screen when trying to move while the camera locks the player character's rotation. I believe it's because the TPController is rotating the character while the camera is constantly trying to lock the character in a certain rotation. The code I have under the right mouse button part is this:
`Player.transform.rotation = Quaternion.Euler(gameObject.transform.eulerAngles.x,Camera.main.transform.eulerAngles.y,Time.deltaTime * 0.01);`
...and here's the rotation/direction part that's used when not in the camera-locked mode, which works just fine (extracted from standard Third Person Controller)
moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000);
moveDirection = moveDirection.normalized;
When not trying to move the character, it behaves fine, but when trying to move the character, it goes berserk, the character keeps stuttering across the screen. Can anyone help me?
Your answer
Follow this Question
Related Questions
Hitman Absolution Camera Study 0 Answers
Help, please with rotation input 0 Answers
nullifying targetObject after a Smooth LookAt Transition 2 Answers