- Home /
Question by
SubbyDev · Feb 09, 2020 at 11:14 AM ·
camera rotatethird-personthird person controllerclamped rotationthird-person-camera
i have to clamp a third person camera,I am trying to make a third person camera clamp.
I would like to clamp my third person camera, now it can turn on the X-axis (and the whole body will turn too) and it can turn on the Y-axis (and the head will turn too).
Right now i have this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
public float mouseSensivityHor = 100f;
public float mouseSensivityVer = 50f;
public Transform playerBody;
public Transform playerHead;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensivityHor * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensivityVer * Time.deltaTime;
playerBody.Rotate(Vector3.up * mouseX);
playerHead.Rotate(Vector3.forward * mouseY);
}
}
Comment