Search Unity

Changing Animations via Code, got an error when using a Substate animation.

Discussion in 'Scripting' started by MrZeker, Aug 22, 2020.

  1. MrZeker

    MrZeker

    Joined:
    Nov 23, 2018
    Posts:
    227
    Hello

    I want to do a button to swap the actors in an animation. Essentially making Character 1 play the animation Character 2 was playing, and Character 2 play the animation Character 1 was previously playing.

    Here is what im doing.

    I use a String (Char1Anim) to get the name of the current animation on Character 1 (and 2), and then i call

    Playeranim.play(Char1Anim);

    And the same for character 2.
    However, when i try to use this with an animation that resides inside a substate machine i get the error that the animation state cannot be found.
    How can i fix this?
    As you can see by the procedure, there is no error with the animation names. And i cannot take all the other (over 1000) aniamtions outside of the sub-state machines.

    Any help would be very appretiated.
     
  2. MrZeker

    MrZeker

    Joined:
    Nov 23, 2018
    Posts:
    227
    Help?
     
  3. MrZeker

    MrZeker

    Joined:
    Nov 23, 2018
    Posts:
    227
    Anyone?