I have a Cube on (0,2,0) and I want it to move on the y axis from 2 down to 1 and then up to 3 back to 1 back to 3 and so on...
Can someone explain me, what to pass in as parameters when using Mathf.PingPong()
?
I have
public virtual void PingPongCollectable(Transform transform, float speed)
{
Vector3 pos = transform.position; // current position
pos.y = Mathf.PingPong( ? , ? ); // missing parameters, calculate new position on y
transform.position = pos; // new position
}
so where do I have to pass in the speed and the coordinates A (above) and B (below) ?
The cube should just smoothly slide up and down in a loop.
Thanks!