Why is my animation being started, but is not actually playing?
As you can see in the first picture, my pause menu defaults to not showing, and it does this fine. But, when I set a Boolean called "pause" to true, my animation controller successfully transitions the animations but the animation immediately stops and does not play any of it. I am unsure why, as can be seen in the second picture, the animation is not playing even though it transitions successfully.
void Start () {
pauseMenuUI.GetComponent<PauseMenuUI>().m_Anim.SetBool("Pause", false);
Time.timeScale = 1;
}
This code is in the void start, and initially sets the Boolean for pause to false.
void Update () {
if (Input.GetKeyDown(KeyCode.Escape))
{
print("Open Pause Menu");
Time.timeScale = 0;
pauseMenuUI.GetComponent<PauseMenuUI>().m_Anim.SetBool("Pause", true);
}
}
This code sets the Boolean of pause to true when escape it hit. Please reply back because I cannot find an answer to this problem anywhere.
Answer by projectmousagaming · Apr 06, 2016 at 10:38 PM
@Mavina Okay, it was because I was setting Time.timeScale = 0, which was forcing all animations to stop. Do you know anyway that I can pause my game but still have certain animations play?
I call a method something like this at the end of a level:
public void DisableEnemies() { Enemy[] objs = Object.FindObjectsOfType(); if (objs.Length > 0) { foreach (Enemy obj in objs) { obj.enabled = false; } } }
Okay, I actually decided against making it pause the game when the menu is opened, because I feel it would work better with my game. Thanks for the help anyway!
Not sure what you were trying to do but I use a nice asset called Platformer Pro (a little pricey $60 but worth the money I$$anonymous$$HO). But it has a feature for pausing the game (for example press the escape key to show a menu) and everything stops except background animations.
Your answer
Follow this Question
Related Questions
Animation doesn't switch to default state after setActive 2 Answers
Syncing Animations both playing from Seperate Animators 0 Answers
Problem with animated image on canvas 0 Answers
Unity 2d animation time over cursor/obj pos 0 Answers
Attach more than one skinned meshrenderer to same animator. 1 Answer