Another way using the scripts above is to change cameraMoveSpeed gradually downwards as you approach your target.
So you would leave cameraMoveSpeed alone and make a new local variable in CameraUpdater();
That variable would be initially cameraMoveSpeed.
Then you would compute the distance from target.position to transform.position and when it gets below a certain distance, you would begin to slow cameraMoveSpeed down to a miminum version of it.
For instance (I am just typing this, not compiling it):
// this is the presumed speed we will use
float tempSpeed = cameraMoveSpeed;
// until we get close
float distance = Vector3.Distance (target.position, transform.position);
float close = 2.0f; // change as needed
if (distance < close)
{
// now we need to adjust tempSpeed from its max down to its minimum slowly
float slowestCameraSpeed = 0.5f; // we'll slow to this value
float alpha = distance / close; // alpha will go from 1.0f to 0.0f
// now we lerp to the slower speed as alpha goes from 1.0 to 0.0
tempSpeed = Mathf.Lerp( slowestCameraSpeed, tempSpeed, alpha);
}
tempSpeed = tempSpeed * Time.deltaTime;
// now you can use tempSpeed in place of step with your original Vector3.MoveTowards() function.
I like to understand what I’m doing because it helps my brain form new connections and understand more things in Unity and gamedev in general, so I’m happy to develop some step-by-step operations that I can understand today, as well as two years from now if I dig this code up again.
So for now my “CameraFollowing” does work with damping,
i did it a bit simplier as i found in the Unity.Doc a simple function,
void CameraUpdater()
{
// set the target object to follow
Transform target = CameraFollowObj.transform;
//move towards the game object that is the target
float step = cameraMoveSpeed * Time.deltaTime;
//If Damping is "on", the Camera will Damp depending on the Smooth value
if(useCameraFollowDamping){
transform.position = Vector3.SmoothDamp(transform.position, target.position, ref velocity, followDamping);
return;
}
transform.position = Vector3.MoveTowards(transform.position, target.position, step);
}
so now i still need kind of “Damping” for my “Rotation”, if i get something, i will Update it here