- Home /
 
LeanTween reverse tween
Is it possible to reverse a tween? I am working on a wall running script and I can not make the camera go back smoothly it just snaps back.
Here is the code.
     if (isWallRunning)
     {
         if (leftRight.Equals("left") || leftRight.Equals("right"))
         {
             return;
         }
         if (leftHit.collider)
         {
             float direction = -1f;
             LTDescr rotateOut = LeanTween.rotateLocal(playerCam.gameObject, new Vector3(0, 0, 12.5f * direction), timeToSnap);
             leftRight = "left";
             _rb.useGravity = false;
         }
         if (rightHit.collider)
         {
             float direction = 1f;
             LTDescr rotateOut = LeanTween.rotateLocal(playerCam.gameObject, new Vector3(0, 0, 12.5f * direction), timeToSnap);
             leftRight = "right";
             _rb.useGravity = false;
         }
     }
     else
     { 
         if (leftRight.Equals("none"))
         {
             return;
         }
         if (leftRight.Equals("left"))
         {
             float direction = 1f;
             LTDescr rotateOut = LeanTween.rotateLocal(playerCam.gameObject, new Vector3(0, 0, 12.5f * direction), timeToSnap);
             //LeanTween.cancel(playerCam.gameObject);
             _rb.useGravity = true;
             Debug.Log("test left");
         }
         if (leftRight.Equals("right"))
         {
             float direction = -1f;
             LTDescr rotateOut = LeanTween.rotateLocal(playerCam.gameObject, new Vector3(0, 0, 12.5f * direction), -timeToSnap);
             //LeanTween.cancel(playerCam.gameObject);
             _rb.useGravity = true;
             Debug.Log("test right");
         }
         leftRight = "none";
     }
 
               Can someone help?
               Comment
              
 
               
              Answer by dmitriyl · Aug 19, 2020 at 04:07 PM
Tweening forward and backward is possible with Ext.LeanTween.Framework.LTDescr.setLoopPingPong with argument 1.
Like: LeanTween.value(target) .setLoopPingPong(1);
Your answer