unity3d uniform back-and-forth movement between two points

Hits: 0

        var a = new Vector3(0, 0, 0);
        var b = new Vector3(0, 5, 0);

        float pingPong = Mathf.PingPong(Time.time, duration);
        float p = Mathf.InverseLerp(0, duration, pingPong);
       transform.position =Vector3.Lerp(a, b, p);

You may also like...

Leave a Reply

Your email address will not be published.