Merge remote-tracking branch 'origin/Dev' into origin/LevelDesign

This commit is contained in:
Alain Abboud 2022-10-27 00:21:43 -04:00
commit 0d86a0a5e0
5 changed files with 61 additions and 5 deletions

View File

@ -9,6 +9,6 @@ PhysicMaterial:
m_Name: Player m_Name: Player
dynamicFriction: 0 dynamicFriction: 0
staticFriction: 0 staticFriction: 0
bounciness: 1 bounciness: 0.7
frictionCombine: 0 frictionCombine: 0
bounceCombine: 0 bounceCombine: 0

View File

@ -274,13 +274,15 @@ MonoBehaviour:
rb: {fileID: 1772573266731274174} rb: {fileID: 1772573266731274174}
canWalk: 1 canWalk: 1
canJump: 1 canJump: 1
movementSpeed: 0.8 movementSpeed: 0.3
maxMovementSpeed: 20
jumpPower: 3 jumpPower: 3
afterJumpHorizontalSlowdownTime: 1 afterJumpHorizontalSlowdownTime: 1
groundDrag: 1 groundDrag: 1
airDrag: 0 airDrag: 0
playerHeight: 0.6 playerHeight: 0.6
jumpAirSlowdown: 80 jumpAirSlowdown: 80
grappleHook: {fileID: 1772573266731274173}
isGrounded: 0 isGrounded: 0
--- !u!114 &8474203461765366282 --- !u!114 &8474203461765366282
MonoBehaviour: MonoBehaviour:

View File

@ -1961,6 +1961,16 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 1772573266731274163, guid: 4dbf735f9da7b9f43b69f1577e4e5763,
type: 3}
propertyPath: grappleHook
value:
objectReference: {fileID: 1341139412}
- target: {fileID: 1772573266731274163, guid: 4dbf735f9da7b9f43b69f1577e4e5763,
type: 3}
propertyPath: maxMovementSpeed
value: 20
objectReference: {fileID: 0}
- target: {fileID: 1772573266731274171, guid: 4dbf735f9da7b9f43b69f1577e4e5763, - target: {fileID: 1772573266731274171, guid: 4dbf735f9da7b9f43b69f1577e4e5763,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name
@ -1976,6 +1986,11 @@ PrefabInstance:
propertyPath: hitMarkerRect propertyPath: hitMarkerRect
value: value:
objectReference: {fileID: 1301531513} objectReference: {fileID: 1301531513}
- target: {fileID: 1772573266731274174, guid: 4dbf735f9da7b9f43b69f1577e4e5763,
type: 3}
propertyPath: m_Constraints
value: 88
objectReference: {fileID: 0}
- target: {fileID: 1772573266731274175, guid: 4dbf735f9da7b9f43b69f1577e4e5763, - target: {fileID: 1772573266731274175, guid: 4dbf735f9da7b9f43b69f1577e4e5763,
type: 3} type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
@ -2039,6 +2054,18 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 1341139406} m_PrefabInstance: {fileID: 1341139406}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!114 &1341139412 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1772573266731274173, guid: 4dbf735f9da7b9f43b69f1577e4e5763,
type: 3}
m_PrefabInstance: {fileID: 1341139406}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f45bd04209bb424e8b1f5271cb16ab0, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1530935835 --- !u!1 &1530935835
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -13,6 +13,7 @@ public class CharacterMovement : MonoBehaviour
[Header("Movement settings")] [Header("Movement settings")]
[SerializeField] private float movementSpeed; [SerializeField] private float movementSpeed;
[SerializeField] private float maxMovementSpeed;
[SerializeField] private float jumpPower; [SerializeField] private float jumpPower;
[SerializeField] private float afterJumpHorizontalSlowdownTime; [SerializeField] private float afterJumpHorizontalSlowdownTime;
@ -21,6 +22,7 @@ public class CharacterMovement : MonoBehaviour
[SerializeField] private float airDrag; [SerializeField] private float airDrag;
[SerializeField] private float playerHeight; [SerializeField] private float playerHeight;
[SerializeField] private float jumpAirSlowdown; [SerializeField] private float jumpAirSlowdown;
[SerializeField] private GrappleHook grappleHook;
public bool isGrounded; public bool isGrounded;
private bool isStunned = false; private bool isStunned = false;
@ -47,6 +49,7 @@ public class CharacterMovement : MonoBehaviour
stopWalk = false; stopWalk = false;
} }
SpeedControl();
} }
private void FixedUpdate() private void FixedUpdate()
@ -117,11 +120,30 @@ public class CharacterMovement : MonoBehaviour
float inputMovement = value.ReadValue<float>(); float inputMovement = value.ReadValue<float>();
rb.velocity = new Vector3(rb.velocity.x, jumpPower * inputMovement, rb.velocity.z); rb.velocity = new Vector3(rb.velocity.x, jumpPower * inputMovement, rb.velocity.z);
//rawInputMovement = new Vector3(rawInputMovement.x, jumpPower, rawInputMovement.z); //rawInputMovement = new Vector3(rawInputMovement.x, jumpPower, rawInputMovement.z);
if (inputMovement == 1f) }
}
private void SpeedControl()
{
if (grappleHook.isGrappled())
{
Vector3 flatVel = rb.velocity;
if (flatVel.magnitude > maxMovementSpeed)
{ {
Debug.Log("start jump"); Vector3 limitedVel = flatVel.normalized * maxMovementSpeed;
rb.velocity = limitedVel;
}
}
else
{
Vector3 flatVel = new Vector3(rb.velocity.x, 0f, rb.velocity.z);
if (flatVel.magnitude > maxMovementSpeed)
{
Vector3 limitedVel = flatVel.normalized * maxMovementSpeed;
rb.velocity = new Vector3(limitedVel.x, rb.velocity.y, limitedVel.z);
} }
} }
} }
} }

View File

@ -44,6 +44,11 @@ public class GrappleHook : MonoBehaviour
private Vector3 currGrappleEndPos; private Vector3 currGrappleEndPos;
private GameObject hookedTo; // The obj we are hooked to private GameObject hookedTo; // The obj we are hooked to
public GameObject HookedTo{get => hookedTo; set => hookedTo = value;} public GameObject HookedTo{get => hookedTo; set => hookedTo = value;}
public bool isGrappled()
{
return grappled;
}
#region private methods #region private methods
void Start() void Start()