Search Unity

Play Animation state machine at edit time.

Discussion in 'Animation' started by hawaiian_lasagne, Nov 15, 2019.

  1. hawaiian_lasagne

    hawaiian_lasagne

    Joined:
    May 15, 2013
    Posts:
    124
    Hi,

    I have setup a reasonably complex statemachine. The states changes are mainly triggers emitted by code.

    Is there a way to 'play' this state machine in the edit (along with animations) and trigger the transitions somehow? Or should I write a custom edit script that will do this for me?

    Cheers
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    You can't do it out of the box so you will need an editor script (though I've never tried doing it with an Animator Controller so I'm not even sure if it's possible).

    But it's definitely possible if you use the Playables API (Animancer allows animations to be played in Edit Mode). One thing to be aware of is that it doesn't work properly in Unity versions older than 2018.3 and I expect the same limitation would apply to Animator Controllers.
     
  3. hawaiian_lasagne

    hawaiian_lasagne

    Joined:
    May 15, 2013
    Posts:
    124
    Animancer looks interesting, thanks for the headsup!

    I ended up just creating an empty scene with only my character in it. Then setup key events in a script to trigger the different state machine parameters in game mode. Works OK. It would be nicer if unity supported state machine playback at edit time though.