Question by
ninjalemur · Jul 02, 2017 at 08:59 AM ·
cameras
Third person camera script not working
I have made a third person camera script, put it ina working character but it does nothing, here it is:
using UnityEngine;
public class ThirdPersonCamera : MonoBehaviour {
public Transform lookAt;
public Transform camTransform;
private Camera cam;
private float distance = 10.0f;
private float currentX = 0.0f;
private float currentY = 0.0f;
private void start()
{
camTransform = transform;
cam = Camera.main;
}
private void Update()
{
currentX += Input.GetAxis("mouseX");
currentX += Input.GetAxis("mouseX");
}
private void LateUpdate()
{
Vector3 dir = new Vector3(0,0,-distance);
Quaternion rotation = Quaternion.Euler(currentY,currentX,0);
camTransform.position = lookAt.position + rotation * dir;
}
}
Comment