add: damage to lava

update: moved player gravitation to FixedUpdate
update: GameController initialization is moved to Awake
This commit is contained in:
KOSMOGOR
2025-05-01 21:29:06 +03:00
parent e514bb62ab
commit 8dd89dafa2
8 changed files with 110 additions and 11 deletions
+7 -4
View File
@@ -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() {