コード例 #1
0
    void Jumping()
    {
        if (mov2D.Grounded)
        {
            jump       = false;
            doubleJump = false;
        }

        if (!doubleJump && (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.X)))
        {
            Vector3 jumpDir = GetJumpDir();

            CheckRollIntent(jumpDir.y);

            Vector3 residualVelocity = GetResidualVelocity(jumpDir);

            if (mov2D.Grounded)
            {
                Jump(jumpDir, residualVelocity);
            }
            else if (!doubleJump)
            {
                DoubleJump(jumpDir, residualVelocity);
            }
            else if (mov2D.WallLean != 0)
            {
                doubleJump = true;
                //mov2D.SetVel(jumpDir * JUMP_FORCE);
                if (!mov2D.GetRollIntent())
                {
                    mov2D.SetVel((jumpDir + Vector3.up + Vector3.right * mov2D.WallLean).normalized * JUMP_FORCE);
                }
                else
                {
                    mov2D.SetVel((jumpDir + Vector3.right * mov2D.WallLean).normalized * JUMP_FORCE);
                }
            }
        }
    }