[SOLVED]EvaluatedAttackChain not resetting to 0 after any attacks

I’m having this strange problem where the evaluatedAttackChain variable is not going back to 0. I’ve compared my attack method to the final version of chapter 8, but it all seems to check out fine. This is causing my attack button press to perform the entire combo without even needing to keep pressing the button and if I land from a jump attack, my character goes directly into the punch to continue the string.

EvaluatedChain integer is always above 0.

Any help would be appreciated.

@nathansimbahan Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hello yinyamina,

EvaluatedChain not resetting back to zero can be caused by multiple things. Here are a few pointers in fixing this.

First, check if the hero_attack1_anim animation has a DidChain animation event. This event will cause the hero to reset the EvaluatedChain value.

Next, check if the HeroCallback script in the HeroAnimator gameObject contains the

public void DidChain(int chain) {
hero.DidChain(chain);
}

method. If this is missing, the animation event won’t know which method to call and thus causing the EvaluatedChain to not be reset.

Also, double-check if the hero variable is not set in the Inspector, this might cause a few issues.

If this doesn’t solve your issues, could you provide more details?

Thanks!

Here’s my setup:
Imgur: The magic of the Internet. png

Imgur: The magic of the Internet. png

(New users can only post one image. the . png has a space between it.)
Here is a visual of the problem.

https://streamable.com/f4fb6

I’ve moved on with the lessons, but I’m still having this issue. Hoping someone can help me out with it! I’d like to know where I went wrong. I only noticed it as I was coding the jump attack. My jump attack kept repeating and when landing from a jump attack, my character would go into the punch animation. I’m not sure if it was there all along, since before that, we only had 1 punch coded.

Hello yinyama,
If everything is set correctly, can you check if the transition to the attack has a transition duration of 0?

Usually, if the transition has a duration value, the animation event on the first animation will not be called.

Hi Nathan,

Yes, I’ve checked my animations and the duration of them are all set to 0.
The settings for all of them look like this:
Imgur: The magic of the Internet. png The evaluated chain int is the only thing different since that is what corresponds to the specific attack.

Is there anything else I can check?

I’ve compared data with the demo that came with the book, but I can’t really find where I went wrong.

A thing I’ve also noticed after doing the damage numbers is that my attacks (combos, not jump atk or run atk) are not following the AttackData data. It seems to only be taking information from the normal attack 1 data. Maybe it can be related to the main problem?

Hi @yinyamina,

I’ve noticed on your screenshot that your transition has the condition CurrentChain greater than 0 and EvaluatedChain less than 5,

The conditions for the punches should be:
CurrentChain greater than 0 and EvaluatedChain less than 1 on the first attack, CurrentChain greater than 1 and Evaluated Chain less than 2 on the second attack,
and so on. This way, only one attack should be processed at a time when pressing the attack button.

I tried out a project on my end where I changed all the attack transition condition to CurrentChain greater than 0 and the character now plays the whole combo when pressing the attack just once.

Hope this helps you out.

Hi Nathan,
Oooooh I get it now. My current chains were all set to 0. I’m going to try that now and see if it fixes the problem. If so, I can’t believe I overlooked that -_-

That fixed the issue! Thanks Nathan :smiley: We can mark this as solved!
I’m now having a separate issue now though. If I can’t fix it I will create a new topic.