::This is covered in Part 6. When your HitStopTime()
freezes the game when you get hit, RestoreTimeScale()
(Or whatever the method that is supposed to restore the time is named for you) is called.
Howver, it only works when it is active in Update()
. Unfortunately, we seem to have placed it below the return line for when you dash. Therefore, when you dash and get hit, time does not resume and thus you “crash”.
The reason you flash is because StopTakingDamage()
instantiates the blood particles. But if that particle doesn’t exist, it fails to continue the rest of its code, causing an error and leaving you as invincible, thus making FlashWhileInvincible()
on.
So, just put your RestoreTimeScale()
above in the Update()
method as it doesn’t need to be stopped anytime.
void Update()
{
...
RestoreTimeScale();
if (pState.dashing) return;
RestoreTimeScale();
...
}