Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class camMouseLook : MonoBehaviour
- {
- Vector2 mouseLook;
- Vector2 smoothV;
- public float sensitivity = 5.0f;
- public float smoothing = 2.0f;
- public GameObject Character;
- void Uptade()
- {
- var md = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
- md = Vector2.Scale(md, new Vector2(sensitivity * smoothing, sensitivity * smoothing));
- smoothV.x = Mathf.Lerp(smoothV.x, md.x, 1f / smoothing);
- smoothV.y = Mathf.Lerp(smoothV.y, md.y, 1f / smoothing);
- mouseLook += smoothV;
- transform.localRotation = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
- Character.transform.localRotation = Quaternion.AngleAxis(mouseLook.x, Character.transform.up);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement