Search Unity

Changing scenes at the end of animation key frame not working

Discussion in 'Scripting' started by ndmrzk, Mar 18, 2020.

  1. ndmrzk

    ndmrzk

    Joined:
    Jul 25, 2018
    Posts:
    35
    Hello, Im trying to change scenes after an animation ends but i dont know whats not working. In inspector I got an Image with an Animator component attached. In Animation window i have setup the animation that I want. I added an event after the last frame of the animation with script attached. The script is like this :

    Code (CSharp):
    1.  
    2. public void LoadNewScene()
    3. {
    4.     SceneManager.LoadSceneAsync(1);
    5. }
    6.  
    in app, i got a black screen then the animation plays then crash. doesnt change to the scene i assigned it to.
     
  2. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    What do you mean by 'crash'? Do you get an error?

    Also, do you know if your scene loads normally, i.e. without using Async? Since you are loading the scene asynchronously, it may be better to load it via a Coroutine as described here.