Hi,
I’m trying to make the main camera follow a car from sideview letting the car accelerate first while looking at it and then following it shortly after and my script below works but the actual following of the camera is choppy and I’m not sure why. I’d like it to be totally a smooth movement, can anybody help?
// camera will follow this object
public Transform Target;
//camera transform
public Transform camTransform;
// offset between camera and target
public Vector3 Offset;
// change this value to get desired smoothness
public float SmoothTime = 0.3f;
// This value will change at the runtime depending on target movement. Initialize with zero vector.
private Vector3 velocity = Vector3.zero;
private void Start()
{
Offset = camTransform.position - Target.position;
}
private void LateUpdate()
{
//update position
Vector3 targetPosition = Target.position + Offset;
camTransform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, SmoothTime);
// update rotation
transform.LookAt(Target);
}