so I’m fairly new to scripting and I got this script online
var target : Transform;
var distance = 3.0;
var height = 3.0;
var damping = 5.0;
var smoothRotation = true;
var rotationDamping = 10.0;
var lockRotation : boolean;
function Update () {
target = GameObject.FindGameObjectWithTag("Player").transform;
var wantedPosition = target.TransformPoint(0, height, -distance);
transform.position = Vector3.Lerp (transform.position, wantedPosition, Time.deltaTime * damping);
if (smoothRotation) {
var wantedRotation = Quaternion.LookRotation(target.position - transform.position, target.up);
transform.rotation = Quaternion.Slerp (transform.rotation, wantedRotation, Time.deltaTime * rotationDamping);
}
else transform.LookAt (target, target.up);
if(lockRotation)
transform.localRotation = Quaternion.EulerAngles(0,0,0);
}
this makes the camera follow the player smoothly and I’ve been playing around with it for a while but I can’t figure out how to add a variable that would make the camera only follow the target on the x axis. How would I do this? thank you.