Question by
aydenmullin20001403 · Mar 19, 2020 at 03:54 PM ·
rotationcamera rotatecamera movement
rotating camera jumping around y axis?
I am following a tutorial on a 3rd person script, I have a script to reference the camera pivot and camera around the camera pivots y axis. this works, however there is a small "jump" in the cameras rotation when moving the mouse, its hard to see but in slow motion it is clear that it is happening, any ideas?
this is my script from this tutorial https://www.youtube.com/watch?v=ORD7gsuLivE
{ using System.Collections; using System.Collections.Generic; using UnityEngine;
public class playerMovement : MonoBehaviour { public Transform camPivot; float heading = 0; public Transform cam;
public float x;
public float y;
Vector2 input;
void Update()
{
heading += Input.GetAxis("Mouse X") * Time.deltaTime * 180;
camPivot.rotation = Quaternion.Euler(0, heading, 0);
input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
input = Vector2.ClampMagnitude(input, 1);
Vector3 camF = cam.forward;
Vector3 camR = cam.right;
camF.y = 0;
camR.y = 0;
camF = camF.normalized;
camR = camR.normalized;
//transform.position += new Vector3(input.x,0,input.y) *Time.deltaTime”S5;
transform.position += (camF * input.y + camR * input.x) * Time.deltaTime * 5;
x = Input.GetAxis("Mouse X");
y = Input.GetAxis("Mouse Y");
}
} }
Comment