Exemplo n.º 1
0
    private void Jump()
    {
        // //jump direction is only up when its the first jump.
        // //otherwise we just whatever direction we jumped in before
        // //for any jumps after the first

        // if (currJumps == 0)
        // {
        //     jumpDir = thisTransform.up;
        // }

        // /*------------------------------------------------------
        // //Addes Force to the player in the up direction
        // -------------------------------------------------------*/

        // body.AddForce(jumpDir * jumpPower, ForceMode2D.Impulse);
        // currJumps++;
        Transform gravityEdge = currentPlanet.GetComponent <CircleCollider2D>().transform;
        Vector2   position    = thisTransform.position;

        if (currJumps == 0)
        {
            position = new Vector2(gravityEdge.position.x / 2, gravityEdge.position.y / 2);
        }
        if (currJumps == 1)
        {
            position = new Vector2(gravityEdge.position.x, gravityEdge.position.y);
        }
        body.MovePosition(position);
    }