(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:
		@@ -40,7 +40,7 @@ Transform:
 | 
			
		||||
  - {fileID: 5885597207531562994}
 | 
			
		||||
  - {fileID: 5885597208269163161}
 | 
			
		||||
  m_Father: {fileID: 0}
 | 
			
		||||
  m_RootOrder: 0
 | 
			
		||||
  m_RootOrder: 9
 | 
			
		||||
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 | 
			
		||||
--- !u!212 &5885597207104481987
 | 
			
		||||
SpriteRenderer:
 | 
			
		||||
@@ -251,17 +251,12 @@ MonoBehaviour:
 | 
			
		||||
  m_Script: {fileID: 11500000, guid: 7b873819f9a3f36ef898a0403972da28, type: 3}
 | 
			
		||||
  m_Name: 
 | 
			
		||||
  m_EditorClassIdentifier: 
 | 
			
		||||
  maxRunSpeed: 10
 | 
			
		||||
  runAcceleration: 10
 | 
			
		||||
  snappiness: 2.5
 | 
			
		||||
  jumpSpeed: 5
 | 
			
		||||
  airSpeedMultiplier: 0.5
 | 
			
		||||
  groundLayer:
 | 
			
		||||
  Data: {fileID: 11400000, guid: fec218a9d55267dedac6ebe31eab6dcd, type: 2}
 | 
			
		||||
  _groundCheckSize: {x: 0.49, y: 0.93}
 | 
			
		||||
  _wallCheckSize: {x: 0.5, y: 1}
 | 
			
		||||
  _groundLayer:
 | 
			
		||||
    serializedVersion: 2
 | 
			
		||||
    m_Bits: 64
 | 
			
		||||
  boxSize: {x: 0.03, y: 0.21}
 | 
			
		||||
  maxDistanceFromGround: 0.22
 | 
			
		||||
  stateController: {fileID: 0}
 | 
			
		||||
--- !u!95 &2772748892378701928
 | 
			
		||||
Animator:
 | 
			
		||||
  serializedVersion: 5
 | 
			
		||||
@@ -595,7 +590,7 @@ LineRenderer:
 | 
			
		||||
  m_LightmapParameters: {fileID: 0}
 | 
			
		||||
  m_SortingLayerID: 0
 | 
			
		||||
  m_SortingLayer: 0
 | 
			
		||||
  m_SortingOrder: 0
 | 
			
		||||
  m_SortingOrder: 2
 | 
			
		||||
  m_Positions:
 | 
			
		||||
  - {x: 0, y: 0, z: 0}
 | 
			
		||||
  - {x: 0, y: 0, z: 1}
 | 
			
		||||
 
 | 
			
		||||
@@ -2725,18 +2725,6 @@ PrefabInstance:
 | 
			
		||||
      propertyPath: m_camera
 | 
			
		||||
      value: 
 | 
			
		||||
      objectReference: {fileID: 519420031}
 | 
			
		||||
    - target: {fileID: 5559747613460074786, guid: 576d3fc87874f426294e4bbacb171478, type: 3}
 | 
			
		||||
      propertyPath: Data
 | 
			
		||||
      value: 
 | 
			
		||||
      objectReference: {fileID: 11400000, guid: fec218a9d55267dedac6ebe31eab6dcd, type: 2}
 | 
			
		||||
    - target: {fileID: 5559747613460074786, guid: 576d3fc87874f426294e4bbacb171478, type: 3}
 | 
			
		||||
      propertyPath: _groundCheckSize.y
 | 
			
		||||
      value: 0.93
 | 
			
		||||
      objectReference: {fileID: 0}
 | 
			
		||||
    - target: {fileID: 5559747613460074786, guid: 576d3fc87874f426294e4bbacb171478, type: 3}
 | 
			
		||||
      propertyPath: _groundLayer.m_Bits
 | 
			
		||||
      value: 64
 | 
			
		||||
      objectReference: {fileID: 0}
 | 
			
		||||
    - target: {fileID: 5885597207104481986, guid: 576d3fc87874f426294e4bbacb171478, type: 3}
 | 
			
		||||
      propertyPath: m_RootOrder
 | 
			
		||||
      value: 9
 | 
			
		||||
@@ -2785,10 +2773,6 @@ PrefabInstance:
 | 
			
		||||
      propertyPath: m_Name
 | 
			
		||||
      value: Player
 | 
			
		||||
      objectReference: {fileID: 0}
 | 
			
		||||
    - target: {fileID: 5885597207789090694, guid: 576d3fc87874f426294e4bbacb171478, type: 3}
 | 
			
		||||
      propertyPath: m_SortingOrder
 | 
			
		||||
      value: 2
 | 
			
		||||
      objectReference: {fileID: 0}
 | 
			
		||||
    m_RemovedComponents: []
 | 
			
		||||
    m_RemovedGameObjects: []
 | 
			
		||||
    m_AddedGameObjects: []
 | 
			
		||||
 
 | 
			
		||||
@@ -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