Beispiel #1
0
        public override void Execute(StateManager states)
        {
            if (states.playerLight.isLedgeDetected)
            {
                return;
            }

            // wall run and wall jump
            if (states.inputs.isJumpHold)
            {
                if (states.playerLight.wallDetected && !states.isFacingOppToWall())
                {
                    states.rigid.velocity = new Vector2(0, wallRunSpeed);
                    states.anim.SetTrigger(DefaultAnimParameters.WallRun);
                }
                else if (states.isFacingOppToWall() && !states.playerLight.canSwitchtoDoubleJumpState)
                {
                    states.mTransform.localScale = new Vector3(-1 * states.mTransform.localScale.x,
                                                               states.mTransform.localScale.y,
                                                               states.mTransform.localScale.z);
                    states.playerLight.canSwitchtoDoubleJumpState = true;
                    states.playerLight.wallJumpConfig.canJump     = true;
                }
            }
        }
Beispiel #2
0
        public override void Execute(StateManager states)
        {
            if (states.playerLight.isLedgeDetected && states.movementValues.vertical >= 0)
            {
                return;
            }

            if (!states.inputs.isJumpHold && states.playerLight.wallDetected)
            {
                states.rigid.AddForce(-Physics2D.gravity);

                // pressing down movement
                if (states.movementValues.vertical < 0)
                {
                    states.rigid.velocity = new Vector2(0, activeSlideSpeed);
                }                 // Pressing towards the wall
                else if (!states.isFacingOppToWall() && Mathf.Abs(states.movementValues.horizontal) > 0.1f)
                {
                    states.rigid.velocity = new Vector2(0, idleSlideSpeed);
                }                 // Free fall
                else
                {
                    states.rigid.velocity = new Vector2(0, fallSpeed);
                }
            }
        }
Beispiel #3
0
        public override void Execute(StateManager states)
        {
            if (states.playerLight.isLedgeDetected && states.movementValues.vertical >= 0)
            {
                if (states.movementValues.vertical > 0.1 && states.isFacingOppToWall())
                {
                    states.rigid.constraints = RigidbodyConstraints2D.FreezeRotation;
                    states.rigid.AddForce(Vector2.up * wallJumpForce, ForceMode2D.Impulse);
                    states.playerLight.canSwitchtoDoubleJumpState = true;
                }
                else
                {
                    states.rigid.velocity    = Vector2.zero;
                    states.rigid.constraints = RigidbodyConstraints2D.FreezePosition;
                }

                return;
            }

            if (states.rigid.constraints == RigidbodyConstraints2D.FreezePosition)
            {
                states.rigid.constraints = RigidbodyConstraints2D.FreezeRotation;
            }
        }