- Home /
How would i change this so that a small mouse movement doesnt rotate the camera at the same speed?
I have this but when the mouse moves slow, it rotates at the same speed, how do i fix this? is there a way to detect mouse movement rate?
using UnityEngine;
using System.Collections;
public class PlayerRotation : MonoBehaviour {
public float Sensitivity;
private Vector3 MousePos;
private Vector3 WorldPos;
private float MouseXSet;
void Start () {
MouseXSet = 0;
}
void Update () {
MousePos = Input.mousePosition;
if (MousePos.x > MouseXSet)
{
rigidbody.transform.Rotate (new Vector3 (0, 1, 0) * Sensitivity * Time.deltaTime);
MouseXSet = MousePos.x;
}
if (MousePos.x < MouseXSet)
{
rigidbody.transform.Rotate (new Vector3 (0, -1, 0) * Sensitivity * Time.deltaTime);
MouseXSet = MousePos.x;
}
}
}
Comment