- Home /
Falling then Apply Damage.
I've made a simple falling then Apply Damage script. but when my character jump and then i pressed pause (time scale = 0) the time fixed delta time still increase and apply damage. but when i'm fixing the script and then i'm trying to jump and press pause, this script finally didn't apply damage when pause, but when i'm unpause the game apply damage become 1000+. Now my question is How to make this script not calculating fixed delta time when i'm pausing the game or it will apply damage when the player is grounded (my script apply damage when i'm not grounded).
thanks for reading and answering.
this is my script. iAmFallable is boolean. gotHit Timer = -1.0 fallingRate = 100 fallingTimer = 0 disableJump is boolean
function Update(){
//Debug.Log(fallingTimer);
if(!controller.isGrounded && iAmFallable){
fallingTimer += Time.fixedDeltaTime * fallingRate;
if(fallingTimer > 80 && Time.time > gotHitTimer && !disableJump) ApplyDamage(fallingTimer / 10 + Random.Range(2,15));
}
else if (controller.isGrounded)fallingTimer = 0;
if(health < 0) health = 0;
}
Why not put in a second check, to manually stop it from incrementing falling damage if it detects that the game is paused?
for example,
if(Time.timeScale <= 0)
{
// return or something!
}
Your answer
Follow this Question
Related Questions
Checklist: Object or Character is falling through the floor 12 Answers
raycast and isgrounded dont work 0 Answers
Falling through floor glitch 1 Answer
Collision and character controllers 0 Answers
Player falls through floor after 10-20 seconds and above certain resolution consistantly(Bug?) 5 Answers