(kinda) fixed grapple momentum
also updated the player prefab -- PLEASE remember to override the player prefab with any changes you make to the individual object in the scene
This commit is contained in:
		@@ -41,6 +41,8 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    private Vector2 _moveInput;
 | 
			
		||||
    public float LastPressedJumpTime { get; private set; }
 | 
			
		||||
 | 
			
		||||
    Tutorial_GrapplingRope grapplingRope;
 | 
			
		||||
 | 
			
		||||
    //Set all of these up in the inspector
 | 
			
		||||
    [Header("Checks")]
 | 
			
		||||
    //Size of groundCheck depends on the size of your character generally you want them slightly small than width (for ground) and height (for the wall check)
 | 
			
		||||
@@ -55,6 +57,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    private void Awake()
 | 
			
		||||
    {
 | 
			
		||||
        RB = GetComponent<Rigidbody2D>();
 | 
			
		||||
        grapplingRope = this.gameObject.GetComponent<PlayerBehavior>().grapplingRope;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void Start()
 | 
			
		||||
@@ -269,7 +272,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
 | 
			
		||||
        #region Conserve Momentum
 | 
			
		||||
        //We won't slow the player down if they are moving in their desired direction but at a greater speed than their maxSpeed
 | 
			
		||||
        if (Data.doConserveMomentum && Mathf.Abs(RB.velocity.x) > Mathf.Abs(targetSpeed) && Mathf.Sign(RB.velocity.x) == Mathf.Sign(targetSpeed) && Mathf.Abs(targetSpeed) > 0.01f && LastOnGroundTime < 0)
 | 
			
		||||
        if ((Data.doConserveMomentum && Mathf.Abs(RB.velocity.x) > Mathf.Abs(targetSpeed) && Mathf.Sign(RB.velocity.x) == Mathf.Sign(targetSpeed) && Mathf.Abs(targetSpeed) > 0.01f && LastOnGroundTime < 0) || grapplingRope.isGrappling)
 | 
			
		||||
        {
 | 
			
		||||
            //Prevent any deceleration from happening, or in other words conserve are current momentum
 | 
			
		||||
            //You could experiment with allowing for the player to slightly increae their speed whilst in this "state"
 | 
			
		||||
@@ -367,8 +370,8 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    #region CHECK METHODS
 | 
			
		||||
    public void CheckDirectionToFace(bool isMovingRight)
 | 
			
		||||
    {
 | 
			
		||||
        if (isMovingRight != IsFacingRight)
 | 
			
		||||
            Turn();
 | 
			
		||||
        // if (isMovingRight != IsFacingRight)
 | 
			
		||||
        //     Turn();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private bool CanJump()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user