3rd Person Traversal: Combo Attacks - previousFrameTime

Could someone explain how using the previousFrameTime prevents getting data from the final frame of the previous animation? The simplest terms would be appreciated -struggling with this concept for some reason :grimacing:

Code in question:

if (normalizedTime >= previousFrameTime && normalizedTime < 1f)
        {
            if (normalizedTime >= _attack.ForceTime)
                TryApplyForce(deltaTime);

            if (_stateMachine.InputReader.IsAttacking)
            {
                TryComboAttack(normalizedTime);
            }
        }

Thank you!

Hi DrewOfDonuts,

To make sure I give the best explanation possible, I’m going to be reviewing this section of code, and confer with Nathan. I’ll get back to you soon.

So Nathan and I went over the code, and realized that the previousFrameTime was a remnant of the first draft of the course. The better solution of checking to see if the attack animation is the current clip or the next clip actually resolved the issue. In fact, there are no no circumstances in which if(normalizedTime >=previousFrameTime) would ever be false, so the if statement can be revised to

if(normalizedTime<1f)

and previousFrameTime can be removed from the code. (This would be both the declaration and the previousFrameTime = normalizedTime line at the end of the Tick() method).

Thank you for the clarity! I just kept thinking I’m missing something obvious :sweat_smile:

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

Privacy & Terms