Table of Contents
Wanting to move your Gameobjects back and forth easily?
This code is here just to do that.
- Control the speed and duration of a lerp gameobject.
- Open Unity and add a Cube to the scene.
- Attach the LerpControl.cs script to the Cube.
- Specify the Start Position and End Position of your gameobject.
- Set the speed and duration.
- Press Play in your editor see the magic of LerpControl.
- If the current position is your start position, just check the Get Start Position.
- Play around with the Speed and Duration in Play mode.
- Set another cube in the scene to where you want the end position to be, copy the position and paste it in your End Position.

Quick and easy setup.
Variable | Annotation |
Get Start Position | If enable, the current position of your gameobject will be set to the Start Position. |
Repeatable | Endless looping of the lerp function. |
Copy X | Copies the X axis from the Start Position. |
Copy Y | Copies the X axis from the Start Position. |
Copy Z | Copies the Z axis from the Start Position. |
Start Position | Specifies the Start Position in Vector3. |
End Position | Specifies the End Position in Vector3. |
Speed | Controls the speed of the lerp. |
Duration | Controls the duration of the lerp. |