how to end game when anim stops?

Hi, i am trying to figure out how to end the quit application when the animation ends. if anyone knows how to write this code and have some words teaching me on what the code does i would really appreciate
it :slight_smile:

I would recommend using animation events for finding the end of the animation.

alt text

Just click the Event button and double-click the Event line at end of the animation or where ever else you need to trigger something in code based on an animation.

// this would be somewhere between the start and end brackets of your script class
void EndGame(){ 
Time.timeScale = 0; // this just sets times playback speed of the scene to zero normally it's 1
}

Need to connect the event raised by the animation to the function we just wrote to stop the whole game.
alt text
You can do this by selecting the animation event and put in the function tab the name of the function that your triggering and you might have to fill in the object that is running the script that has the function we wrote. (you don’t need to worry about the float, int, string tabs).

For more information:

https://docs.unity3d.com/ScriptReference/Time-timeScale.html

https://docs.unity3d.com/Manual/script-AnimationWindowEvent.html