Why animations are not playing when I go back to previous scene?

Hi Unity Gurus!

I have 2 scenes in my game.

  1. MainManu scene
  2. Gameplay scene

I am playing animation “Avatar Animation” and “Some leaves” in “MainManu” scene . Avatar animates idle animation and leaves are moving from left to right. Now, When “MainManu” scene executes first time, all animations are working. But, when I go back from gameplay scene to “MainManu” scene animation are not working. Have you any idea about it??

If it runs first time but not the second time then you must have done something wrong with global perimeters!

1- If you’re moving using thirdparty Tween engine check it’s running correctly second time
2- If you’re moving manually changing it’s transform and you have Time.deltaTime in it. Check your Time.timeScale is “1”.

from the docs: Unity - Scripting API: MonoBehaviour.Awake()

Awake is called only once during the lifetime of the script instance

Change Awake() to OnEnable().

from the docs: Unity - Scripting API: MonoBehaviour.OnEnable()

This function is called when the object becomes enabled and active.

Awake will call only once for the script whereas OnEnable will be called each time you reload the scene as long as the object is not set to DontDestoryOnLoad.