- Home /
The question is answered, right answer was accepted
How to add a rotation to this?
I have this 3rd person camera which I need to rotate along with the player objects rotation but added into this input you see in the code.
How do I add(or subtract)the player.rotation into the horizontal axis in this code:
angleH += Mathf.Clamp(Input.GetAxis("Mouse X") + Input.GetAxis(Input.GetAxis("Horizontal"), -1, 1) * hAimingSpeed * Time.deltaTime;
angleH += Mathf.Clamp(Input.GetAxis("Mouse X") + Input.GetAxis(Input.GetAxis("Horizontal"), -1, 1) * hAimingSpeed * Time.deltaTime;
Quaternion aimRot = Quaternion.Euler(-angleV, angleH, angleF);
It because the player starts turning towards the mouse whilst running but the camera does not stay with it. I need it rotate add the players rotation too. Even cancel mouse rotation on the horizontal axis.
If its confusing to you please let me know I will try my best to explain. I really need this fix. I'm so close to getting what I want. Please help.
Answer by DeadKenny · Nov 18, 2013 at 03:24 AM
Never mind figured it out.
angleH += Mathf.Clamp(player.rotation.y, -1, 1) * hAimingSpeed * Time.deltaTime;
... but now its rotating to the opposite direction... lol.
Follow this Question
Related Questions
Using MouseLook script with LookAt function 2 Answers
Child versus Parent rotations 3 Answers
Adjust camera rotation while looking at a target 1 Answer
Camera rotation script logic error? 0 Answers