timeSinceLastAttack substraction

When resetting the timeSinceLastAttack, wouldn’t it be more accurate to have the timeBetweenAttacks substracted like this:

            if (timeSinceLastAttack > timeBetweenAttacks) {
                animator.SetTrigger("attack");
                timeSinceLastAttack -= timeBetweenAttacks;
            }

instead of

            timeSinceLastAttack = 0;

This way we would keep track of the surplus of seconds from the latest frame, wouldn’t we? I fear that this time excess could be important in some future development, or am I just being too paranoid? :grinning_face_with_smiling_eyes:

Nevermind, I see what’s wrong with my approach. I believe it works fine if the player were to be constantly fighting, but as soon as he leaves fight, the timeSinceLastAttack counter keeps getting higher, and when we encounter a fight again, since I never reset it back to zero, timeSinceLastAttack may contain a huge deposit of time which would translate into ‘free kicks without rest’.

That’s exactly right. We always want the delay between attacks to start when we start an attack.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms