public PlayerStateClimbing(PlayerInputScript player, GameObject go) { pi = player; startPosition = pi.GetPlayerTransform().position; startTime = Time.time; ledge = go; //If this is the end of the ledge, and there's no ledge to jump onto, then don't climb if (startPosition == endPosition) { pi.currentState = new PlayerStateHangingOnLedge(pi, ledge); } mi = pi.GetMovementInput(); if (mi.x >= 0.2f) { endPosition = ledge.GetComponent <LedgeScript>().GetRightMostPoint(); } if (mi.x <= -0.2f) { endPosition = ledge.GetComponent <LedgeScript>().GetLeftMostPoint(); } Debug.Log("entering climbing"); }
public override void HandleInput() { if (jumpInput == 0f || jumpProgress > 1f) { pi.currentState = new PlayerStateFalling(pi); } if (pi.playerScript.GetCanClimb() != null) { //Ensure that the player is snapping to the right point, correctly getting the y axis Vector3 p = pi.playerScript.GetCanClimb().GetComponent <LedgeScript>().CalculateCorrectPointToSnapTo(pi.GetPlayerTransform().position); pi.playerScript.SetPlayerPosition(p); pi.currentState = new PlayerStateHangingOnLedge(pi, pi.playerScript.GetCanClimb()); } if (pi.GetDashInput() == 1f && pi.GetCanDash()) { pi.currentState = new PlayerStateDash(pi); } }
public override void HandleInput() { if (superJumpReady && jumpInput == 1f && pi.GetJumpCount() > 0) { pi.currentState = new PlayerStateJumping(pi); } if (pi.IsGrounded()) { pi.currentState = new PlayerStateIdle(pi); } if (pi.playerScript.GetCanClimb() != null) { //Ensure that the player is snapping to the right point, correctly getting the y axis Vector3 p = pi.playerScript.GetCanClimb().GetComponent <LedgeScript>().CalculateCorrectPointToSnapTo(pi.GetPlayerTransform().position); pi.playerScript.SetPlayerPosition(p); pi.currentState = new PlayerStateHangingOnLedge(pi, pi.playerScript.GetCanClimb()); } if (pi.GetDashInput() == 1f && pi.GetCanDash()) { pi.currentState = new PlayerStateDash(pi); } }