Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Animation frozen despite Animator Controller showing animation progress

Discussion in 'Animation' started by andrew210, Nov 23, 2015.

  1. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    241


    As shown in the video, originally the monsters animator is working just fine, however I click a button to change the selected monster and the animations stop playing in Game view despite it still looking like the animator is doing stuff.

    Nothing particularly clever about the code to spawn the monster for this:

    Code (CSharp):
    1.         private void doSpawnMonster(MonsterDataMain aMonster) {
    2.             string monsterBreedName = aMonster.monsterBreedRef.Name;
    3.             monster = aMonster;
    4.             monsterOnDisplay = GameObject.Instantiate ((GameObject) Resources.Load ("Monsters/" + monsterBreedName));
    5.             monsterOnDisplay.transform.position = ranchSpawnPoint.transform.position;
    6.             monsterOnDisplay.transform.SetParent (this.transform);
    7.             RanchviewMonster rm = monsterOnDisplay.AddMissingComponent<RanchviewMonster> ();
    8.             selectedMonster = monster;
    9.         }
    10.  
    11.         public void showMonster(MonsterDataMain aMonster) {
    12.             RanchviewMonster rm = this.GetComponentInChildren<RanchviewMonster>();
    13.             Destroy(rm.gameObject);
    14.             doSpawnMonster(aMonster);
    15.         }
    I've come across a similar issue elsewhere in the game but normally ticking "Apply Root Motion" or just toggling that forces the animation into working for me. Am not sure where to look next for an answer for why this might be happening.
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,528
    Is your animation clip not set to loop?

    Does the clip play on that model in the Inspector's preview?
     
  3. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    241
    Yeah they're all set to loop, they run find in other areas of the game, just when instantiated like this it freezes strangely.
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,528
    Could the instantiated GameObject's Animator be on the wrong GameObject, like a child or parent, so it's not finding the skeleton?
     
  5. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    241
    Sadly not, the first time something is instantiated it works fine, but the second time the animator is frozen. There's no object pooling or anything that might cause strange behaviours, it's a bit of a strange one
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,528
    Does RanchviewMonster's anim field need to be set?

    What happens if you disable and re-enable the Animator during play?

    What if you tick one of the parameters to make it transition to another state?
     
  7. entropicjoey1

    entropicjoey1

    Joined:
    Jun 1, 2014
    Posts:
    26
    I know this is old but I'm having g this exact issue and this is the only post I could find on it, although mine happens when switching animatoroverride controllers after a few switches the players animations freeze but the animator screen is still doing stuff, disabling and enabling don't do anything to help, nor switching the controllers again, making the state transition doesn't help,toggling root motion does nothing, any ideas on what causes this would be super helpful

    Edit; I was breaking the skeleton through parenting during mounting, solved by changing how I handled mounts and chairs etc
     
    Last edited: Sep 8, 2018