Dear all,
I struggle for making a camera follow smooth. My need is to get a camera which smooth follow a target with an offset (z=-10 and y=5). The camera must stay behind the target on turn (like a car game).
Here is the part of the code tried to implement:
public class CameraFollow : MonoBehaviour {
public Transform target;
public float smoothTime = 1.0F;
private Vector3 velocity = Vector3.zero;
void LateUpdate() {
transform.position = Vector3.SmoothDamp(transform.position, target.transform.position + new Vector3(0,5,-10), ref velocity, smoothTime);
transform.LookAt(target);
}
}
Although i use a “smoothDamp” function the result is still not smooth: camera movements are rough.
I also tried by “Lerp” functions like this:
transform.position = Vector3.Lerp(transform.position, target.transform.position + new Vector3(0,5,-10), Time.deltaTime);
transform.LookAt(target);
But when target is reached i have little rough camera movements. Besides i can’t control a good distance between cam and target if target speed increase.
Do you have something that could help me?
Thanks for support,
Dragon