(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:
slevy14 2023-04-27 13:31:04 -07:00
parent 8e221cf94b
commit 863d7e04ef
3 changed files with 12 additions and 30 deletions

View File

@ -40,7 +40,7 @@ Transform:
- {fileID: 5885597207531562994} - {fileID: 5885597207531562994}
- {fileID: 5885597208269163161} - {fileID: 5885597208269163161}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &5885597207104481987 --- !u!212 &5885597207104481987
SpriteRenderer: SpriteRenderer:
@ -251,17 +251,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7b873819f9a3f36ef898a0403972da28, type: 3} m_Script: {fileID: 11500000, guid: 7b873819f9a3f36ef898a0403972da28, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
maxRunSpeed: 10 Data: {fileID: 11400000, guid: fec218a9d55267dedac6ebe31eab6dcd, type: 2}
runAcceleration: 10 _groundCheckSize: {x: 0.49, y: 0.93}
snappiness: 2.5 _wallCheckSize: {x: 0.5, y: 1}
jumpSpeed: 5 _groundLayer:
airSpeedMultiplier: 0.5
groundLayer:
serializedVersion: 2 serializedVersion: 2
m_Bits: 64 m_Bits: 64
boxSize: {x: 0.03, y: 0.21}
maxDistanceFromGround: 0.22
stateController: {fileID: 0}
--- !u!95 &2772748892378701928 --- !u!95 &2772748892378701928
Animator: Animator:
serializedVersion: 5 serializedVersion: 5
@ -595,7 +590,7 @@ LineRenderer:
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 2
m_Positions: m_Positions:
- {x: 0, y: 0, z: 0} - {x: 0, y: 0, z: 0}
- {x: 0, y: 0, z: 1} - {x: 0, y: 0, z: 1}

View File

@ -2725,18 +2725,6 @@ PrefabInstance:
propertyPath: m_camera propertyPath: m_camera
value: value:
objectReference: {fileID: 519420031} 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} - target: {fileID: 5885597207104481986, guid: 576d3fc87874f426294e4bbacb171478, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 9 value: 9
@ -2785,10 +2773,6 @@ PrefabInstance:
propertyPath: m_Name propertyPath: m_Name
value: Player value: Player
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5885597207789090694, guid: 576d3fc87874f426294e4bbacb171478, type: 3}
propertyPath: m_SortingOrder
value: 2
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: [] m_RemovedGameObjects: []
m_AddedGameObjects: [] m_AddedGameObjects: []

View File

@ -41,6 +41,8 @@ public class PlayerMovement : MonoBehaviour
private Vector2 _moveInput; private Vector2 _moveInput;
public float LastPressedJumpTime { get; private set; } public float LastPressedJumpTime { get; private set; }
Tutorial_GrapplingRope grapplingRope;
//Set all of these up in the inspector //Set all of these up in the inspector
[Header("Checks")] [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) //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() private void Awake()
{ {
RB = GetComponent<Rigidbody2D>(); RB = GetComponent<Rigidbody2D>();
grapplingRope = this.gameObject.GetComponent<PlayerBehavior>().grapplingRope;
} }
private void Start() private void Start()
@ -269,7 +272,7 @@ public class PlayerMovement : MonoBehaviour
#region Conserve Momentum #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 //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 //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" //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 #region CHECK METHODS
public void CheckDirectionToFace(bool isMovingRight) public void CheckDirectionToFace(bool isMovingRight)
{ {
if (isMovingRight != IsFacingRight) // if (isMovingRight != IsFacingRight)
Turn(); // Turn();
} }
private bool CanJump() private bool CanJump()