I have two Game objects that should move in To and Fro motion continuously.

Have tried this using ping pong but i couldn’t get smooth movement.

I have also tried this using vector3.lerp,but dint get the desired output.

Please suggest me a solution.

Below is the code i tried using PingPong:

```
m_Bolt1X = m_bolt1.gameObject.transform.localPosition;
m_Bolt1X.x = Mathf.PingPong( Time.time * 1.0f, 1.2f ) - 1.1f;
m_bolt1.gameObject.transform.localPosition = m_Bolt1X;
m_Bolt2X = m_bolt2.gameObject.transform.localPosition;
m_Bolt2X.x = Mathf.PingPong( Time.time * 1.15f , 1.3f ) - 0.7f;
m_bolt2.gameObject.transform.localPosition = m_Bolt2X;
```

Code using Vector3.Lerp:

```
_startPosition = m_bolt1.gameObject.transform.localPosition;
_endPosition = new Vector3(-1.5f,0.9271002f,0f );
m_bolt1.gameObject.transform.localPosition = Vector3.Lerp(_startPosition,_endPosition,Time.time * m_Speed);
if(Vector3.Distance(m_bolt1.gameObject.transform.localPosition,_endPosition) < 0.1f)
{
if(_startPosition.x == -1.5f)
{
_startPosition = m_bolt1.gameObject.transform.localPosition;
_endPosition = new Vector3(-0.5f,0.9271002f,0f );
}
if(_startPosition.x == -0.5f)
{
_startPosition = m_bolt1.gameObject.transform.localPosition;
_endPosition = new Vector3(-1.5f,0.9271002f,0f );
}
```

Where m_bolt1 is one GO and m_bolt2 is second GO.

Have three positions A,B and C. GO 1 should move from B->A anb A->B and GO 2 from B->C and then C->B continuously.