Exemple #1
0
    public void Move(Vector2 moveAmount, bool standingOnPlatform = false)
    {
        State.wasGrounded = State.below;
        UpdateRaycastOrigins();

        State.Reset();
        State.moveAmountOld = moveAmount;

        if (moveAmount.y < 0)
        {
            DescendSlope(ref moveAmount);
        }

        if (moveAmount.x != 0)
        {
            State.faceDir = (int)Mathf.Sign(moveAmount.x);
        }

        HorizontalCollisions(ref moveAmount);
        if (moveAmount.y != 0)
        {
            VerticalCollisions(ref moveAmount);
        }

        transform.Translate(moveAmount, Space.World);

        if (standingOnPlatform)
        {
            State.below = true;
        }

        State.justGotGrounded = State.below && !State.wasGrounded;
    }