Reputation: 3
I was testing my game, and then when I ran the code the camera started doing weird snapping that made camera movement difficult. Here is the script:
public class CameraMovement : MonoBehaviour
{
public float sensX;
public float sensY;
public bool killSwitch;
public Transform orientation;
float yRotation;
float xRotation;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
private void Update()
{
float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;
yRotation += mouseX;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
orientation.rotation = Quaternion.Euler(0, yRotation, 0);
}
}
I tried reloading but that didn't work. I'm really confused because it was working a minute ago.
Upvotes: 0
Views: 45
Reputation: 4059
If you've setup your Input Manager settings incorrectly, you'll likely see a 'Sensitivity' default of 1000
. Which would cause your mouse to be returns hugely large numbers when moving around.
Instead, try a sensitivity of 1
in the Input Manager, and then fine tune it in your Component through the Inspector. The CameraMovement
component sensX
and sensY
were set to 10
in the animation below.
Upvotes: 1