Weird bug upon adding an *untriggered* state transition

I started the challenge by trying to take it on piece by piece and created what seems like a weird bug.

All I did was ad a condition on the transition from Attack to Locomotion using the “stopAttack” trigger but there is no trigger to it in my code anywhere. The result I get is that the Player character does one attack then freezes in a fighting stance. When I click to move the character glides around in a fighting stance. No further attacks are possible even though the line of code " GetComponent().SetTrigger(“attack”);" is being run.

I can’t quite understand what’s happening and why adding a trigger condition to my state diagram (one that is never actually triggered) would result in such a bug an experience.

I’m guessing what’s happening is the “exit time” condition to move from Attack to Locomotion is no longer triggering once I add a trigger.

Transitions happen when conditions are met. Your condition is the stopAttack trigger. Because it is never triggered, the transition never happens and it just sits there at the end, waiting for it to happen.

Even though there is an exit time condition?

So I guess the solution is to have two separate transition lines?

For situations like these, we actually need two transitions from Attack to Locomotion.

One will have HasExitTime checked, but have NO conditions.
The other will have HasExitTime unchecked, but have the condition of stopAttack.

When stopAttack is triggered, it exits using the settings in the transition with HasExitTime unchecked.
due to the condition firing.
When it’s not triggered, at the end of the animation it will transition automatically using the settings in the transition with HasExitTime checked.

1 Like

Yes, what @Brian_Trotter said. I believe with only one transitions, both conditions must be met. It must be within the exit time threshold and the trigger must fire. I could be wrong, though. Never tried it before

That’s correct. StopAttack simply won’t work with only one transition.

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

Privacy & Terms