add: damage to lava
update: moved player gravitation to FixedUpdate update: GameController initialization is moved to Awake
This commit is contained in:
@@ -31,10 +31,13 @@ public class PlayerMovement : MonoBehaviour
|
||||
HandleJumping();
|
||||
HandleMovement();
|
||||
HandleDashing();
|
||||
DoGravity();
|
||||
HandleConstantVelocity();
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
DoGravity();
|
||||
}
|
||||
|
||||
void HandleJumping() {
|
||||
if (movementInactive > 0) return;
|
||||
if (Input.GetKey(KeyCode.Space) && grounded) {
|
||||
@@ -70,12 +73,12 @@ public class PlayerMovement : MonoBehaviour
|
||||
void DoGravity() {
|
||||
if (gravityInactive > 0) {
|
||||
gravityVelocity = Vector3.zero;
|
||||
gravityInactive = Mathf.Max(gravityInactive -= Time.deltaTime, 0);
|
||||
gravityInactive = Mathf.Max(gravityInactive -= Time.fixedDeltaTime, 0);
|
||||
return;
|
||||
}
|
||||
if (grounded && gravityVelocity.y < 0) gravityVelocity = Vector3.zero;
|
||||
gravityVelocity += Physics.gravity * (Time.deltaTime * gravityMultiplier);
|
||||
characterController.Move(gravityVelocity * Time.deltaTime);
|
||||
gravityVelocity += Physics.gravity * (Time.fixedDeltaTime * gravityMultiplier);
|
||||
characterController.Move(gravityVelocity * Time.fixedDeltaTime);
|
||||
}
|
||||
|
||||
void HandleConstantVelocity() {
|
||||
|
||||
Reference in New Issue
Block a user