2D point A to point B platform with jump animation.

Hello everyone,

no idea why img link doesnt work but i will post it here.
Imgur

I am trying to make my char to do a jump animation when the player presses left or right once, and it will jump to that platform.

Right now I am able to do it by transforming the position from A to B at once, but how do I make it from A to B by 2 seconds ( doesnt really matter )

Any help is appreciated!!

            //check the upcoming platform
           selectLeft = Physics2D.Linecast(checkLeftS.position, checkLeftF.position, 1 << LayerMask.NameToLayer("select"));
           selectRight = Physics2D.Linecast(checkRightS.position, checkRightF.position, 1 << LayerMask.NameToLayer("select"));
       
             if (selectLeft.collider != null)
            {
               // Debug.Log(selectLeft.collider.name + " is in front of " + gameObject.name);
                tempL = new Vector3(selectLeft.transform.position.x, selectLeft.transform.position.y - 1);
                canGoLeftS = true;
            }
            else
            {
                canGoLeftS = false;
            }
            if (selectRight.collider != null)
            {
                //Debug.Log(selectRight.collider.name + " is in front of " + gameObject.name);
                tempR = new Vector3(selectRight.transform.position.x, selectRight.transform.position.y - 1);
                canGoRightS = true;
            }
            else
            {
                canGoRightS = false;
            }
            //player input here
                if (Input.GetKeyDown("right") && canGoRightS)
                {
                    transform.position = tempR;
                    //    Debug.Log("go right");
                }

                if (Input.GetKeyDown("left") && canGoLeftS)
                {
                    transform.position = tempL;
                    //  Debug.Log("go left");
                }



!(http://

)

bump

Anything you do in a script happens right now in this frame, e.g. a teleport.

If you want something to happen over multiple frames, you need to move smaller amounts and do so multiple times.

You can do multiple times either by putting logic in an Update() function, or else using a Coroutine. Google for examples of both of those.