Hi again, I’ve tried playing around with it a little and for some reason when the timer is reset to 3 seconds and gets back down to 0 the second time nothing happens in terms of the shooting animation. I have added a few coroutines to be fair so maybe thats why it doesn’t work. Well the timer sort of works but not the loop of the animation and coroutines. I say sort of works because it only loops once and then goes in to negative numbers. This code is only with the countdown reset to test.
In the second countdown the layout is simpler and the countdown resets in a continuous loop as expected:
countdown2 -= Time.deltaTime;
if (countdown2 <= 0.0f)
{
anim.SetBool("Shooting" , false);
Shooting = false;
countdown2 = 6; //<-- reset counter to some value
}
Can you maybe tell me why the animations don’t replay when the timer has reset and why the timer in “countdown” only resets once? I’d really appreciate your help
In the first example, Does the animator bool reset to false at any point? it if remains true and you are just trying to set to each loop, nothing will change
Does it work without the coroutines, something in them affecting the values of cooldown or countdown?
Ah yes of course. That fixed the first issue. I put the countdown reset after the bool is deactivated and now both countdown timers reset regardless of the coroutines. But the animations and instantiations still don’t repeat/loop even though the timer is reset. Do you know why? here’s the whole update function i want looped :
The debug log said the countdown only triggered once while the countdown2 was looping. I then looked at the cooldownTimer = fireDelay; and realised it was supposed to be countdown = fireDelay; now it repeats DD Thank you for the advice and help hpjohn, you’ve been a great help! the debugging was key