Hey guys im curretly working on a 3rd person game and I am using the Unity script “SmoothFollow” as a base for the game Camera.
I would like the camera to play catchup to the players position. For example: the player would move in a direction, then the camera would slowly move to the players new position.
I have tried to implement this behavior into the script many times using but to no success. I understand lerping, damping, etc… but have no idea how to actually implement them correctly into this already existing script provided by Unity:
var wantedRotationAngle = 45;
var wantedHeight = target.position.y + height;
var currentRotationAngle = 5f;
var currentHeight = transform.position.y;
currentRotationAngle = Mathf.LerpAngle(currentRotationAngle, wantedRotationAngle, rotationDamping *Time.deltaTime);
currentHeight = Mathf.Lerp(currentHeight, wantedHeight,heightDamping * Time.deltaTime);
var currentRotation = Quaternion.Euler(0,currentRotationAngle, 0);
transform.position = target.position;
transform.position -= currentRotation * Vector3.forward * distance;
transform.position = new Vector3(transform.position.x,currentHeight, transform.position.z);
transform.LookAt(target);
If anyone has any insight on how I may acheive this, it would be greatly appreciated.
EDIT: I understand that I could use a gameobject that lags behind the player and instead use that as the camera target. It would acheive the desired effect but it isnt really a soloution that I could learn somthing from.