- Home /
Animations Stuck replaying? Overriding Solution.
So I have been at this for HOURS today... I have tried this, tried that, read this watched that, my god... FRIED IS NOT THE WORD TO DESCRIBE!! ;).
Anyways... Ill post my code here for sure, in hopes that you guys can point out what the heck im doing wrong here? But nonetheless, implemented kinda a BURTE/Primitive alternative which worked perfectly.
So What I did to override this. Was implement a Courotine with an IEnbumerator. Delaying the command of forcing the animation to stop by 2 seconds;
Note The "Override" IEnumerator is what my primitive work around was. Id prefer not to do it this way..
As well the If statement That should prevent this animation from replaying as it does... BUt doesnt? :
Any insight or constructive criticism is appreciated!
Enemy AI: ------------- CODE BELOW
private void Die()
{
if(isDead) return;
isDead = true;
GetComponent<Animator>().SetTrigger("die");
// GetComponent<Animator>().enabled = false;
StartCoroutine(OverRideAnimation());
}
IEnumerator OverRideAnimation()
{
yield return new WaitForSeconds(2); // Delay for 2 seconds
GetComponent<Animator>().enabled = false;
}
---------
Answer by tuinal · Jul 26, 2020 at 02:07 AM
You can stop an animation looping by selecting it in the project pane and toggling loop time off in the inspector.
OH $$anonymous$$Y GOD............
DUDE!!!!! NO WONDER!!!!!!!! AAAAHHHHH!!!!!!!
Like I said... FRIED!!! Lol!!!! DUD$$anonymous$$.. I thought entirely it was with my coding... Never did I realize it was looped within the unity animator itself... OH $$anonymous$$Y GOD... THANK YOU DUDE!