I got an Object that I want to move up to Point A and when it reaches Point A it should move to Point B. When it reaches Point B it should move back to Point A.
I thought I could use Vector3.Lerp for this
void Update()
{
transform.position = Vector3.Lerp(pointA, pointB, speed * Time.deltaTime);
}
But how can i move back then? Is there an elegant way to archieve this? Obviously I would need 2 Lerps like this way:
void Update()
{
transform.position = Vector3.Lerp(pointA, pointB, speed * Time.deltaTime); // Move up
transform.position = Vector3.Lerp(pointB, pointA, speed * Time.deltaTime); // Move down
}
Could someone help me out?