# Arc Movement Lerp, Mathf.Sin and Mathf.Pingpong question

Hello everyone, i am trying to move an object from a point to b, and b to a, in short using Mathf.PingPong. But on the way, i want it to make arc movement, like it’s bending. So I have searched a bit and figured out how to make the PingPong lerping, and also how to make the Arc movement. But I couldn’t mix them together, because I couldn’t create logic between timings. Let me clarify the movement I want once more, and then you can look at the script below. I want the object to move from a to b, and have an arc movement with Mathf.Sin, but it should go up only one time in each travel.

``````float t = Mathf.PingPong(Time.time * speed, 1.0f); // ping pong the lerping

currentPos = Vector3.Lerp(startPos, endPos, t);

currentPos.y += bending.y * Mathf.Clamp01(Mathf.Sin(Time.time * 2f)); // clamp the mathf.sin in order to have the bending only in positive way.

go.position = currentPos;
``````

When I change the “2f” value in Mathf.Sin, i am able to adjust the speed of the sin wave, but obviously if i change the speed of ping pong, this changed 2f value will no longer work. I need a value dependent on the time of travel, to multiply with Time.time in Mathf.Sin. But couldn’t create the equation.Can someone help ? Thanks :).

t = Mathf.PingPong(Time.time * speed, 1f);
pos.y = Mathf.Sin(t*Mathf.PI);
pos.x = Mathf.Lerp(start.x, end.x, t);

The angle given to sin is expected at a radian, and so Sin(0) = 0, Sin(PI/2) = 1, Sin(PI) = 0, hence you want to times your t value (which moves from 0 to 1) by PI so that it changes between 0 and PI!