[Request] StateMachineBehaviour OnState Enter/Exit Order change with transition duration > 0

Hello,

When a state changes and the transition duration is 0 the behaviour order is:
Current state OnStateExit
New state OnStateEnter

But when the transition duration is > 0
New state OnStateEnter
Previous state OnStateExit

I (and i know other people who agree) find this annoying that with duration > 0 the new state OnStateEnter is called before the previous state OnStateExit is called.
I would like to use the animator behaviours for more things and not just for animations but currently for me it’s almost usless as a normal state machine if the next state Enter is called before the previous state Exit is called, because i have to make workaround checks to make it usable for me.

So i would like to request that they either change the order so that it is always called in the order OnStateExit → OnStateEnter no matter if the duration is 0 or > 0, or that they make additional methods to override which are called in this order so that everyone can use the method that they need. (But honestly i see no situation where it would make any sense that the next state enter is called before the current state exit, because normally in a state machine the state exit is used for ‘cleanups’ and if i do the cleanups after the next state is already started it doesn’t really make sense because it’s already to late)

So what’s the best way to request such a change/feature, do they read these forums or can i request this somehwere else?

1 Like

Usually you should use https://feedback.unity3d.com/

but in this particular since the duration > 0 both callback would happen on a different frame.

by example if the duration is 0.25
on the frame that the transition would start you will get OnStateEnter for the next state.
and 0.25 second later you will get OnStateExit for the current state.
While you are transitionning from current to next state you may need to run some code in a behaviour to blend out the foot ik weight by example or to create a particule effect.

If you want to use the animator behaviour for other thing than animation and you want it to behave like a FSM then set all your duration to 0 otherwise it will behave like an animation state machine.

1 Like