Hi there, I’m trying to create a nice smooth camera to track a couple of characters. So far I’m using this code and all is well:
void Update()
{
newCameraPosition = Vector3.Lerp (currentCameraPosition, averageWorldPositionCharacters, 0.5f);
deltaCameraPosition = (newCameraPosition - currentCameraPosition);
currentCameraPosition = newCameraPosition;
}
and
void LateUpdate ()
{
transform.Translate ( deltaCameraPosition );
}
So averageworldposition is a point between the two characters I’m tracking. This works great, but I want to add additional code that will move the camera to the right every frame (in addition to the existing movement code), regardless of the position of the characters (so effectively scroll it right at a consistent velocity - so if the characters became stationary, the camera would continue to move to the right).
I tried to simple add this to deltaCameraPosition, so:
transform.Translate (deltaCameraPosition + new Vector3 ( 1.0f, 0.0f, 0.0f );
However this produced some unexpected results, I’m assuming becuase I’m moving the lerp target further away each frame, the distance between the current position and lerp target is greater.
Could anyone advise me as to how to achieve this?
Thanks so much.