- Home /

**closed**Jan 03, 2015 at 07:31 PM by Inan-Evin for the following reason:

The question is answered, right answer was accepted

# 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 :).

Dude you just made me realize the thing, i was so foolish. Thanks dude !

**Answer** by Scribe
·
Jan 03, 2015 at 07:25 PM

```
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!

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Move object in an arc 3 Answers

Moving player in an arc, from startPoint to endPoint 2 Answers

Mathf function on GetKey 1 Answer

Float Count Up & Count Down 2 Answers

how to use time on lerp 2 Answers