I want the camera to follow the player and lag a little bit and then catch up with the player when the player halts. When stopped the player is in the center.
At the moment im at the point where i get the camera to move with the player but i dont know how to get the lag effect!
On the camera object
void Update () {
var newX = player.transform.position.x;
var newZ = player.transform.position.z;
var y = transform.position.y;
transform.position = new Vector3(newX, y, newZ);
}
just a delay or with increasing speed? maybe somethin like this? (not tested, sry) var delay = 0.6; var dT = Time.deltaTime / delay; transform.position = Vector3.Lerp(transform.position, new Vector3(newX, y, newZ), dT);
– sspross