StateMachineBehaviour OnStateFixedUpdate?

Is it possible to extend the StateMachineBehaviour with a OnStateFixedUpdate state? I find it strange that it is not already predefined.

SMB callback are called directly by the animator. So if you animator is setup as Animate Physic all your SMB callback will also be called in the FixedUpdate Loop.

2 Likes

Ok, so with animate physics setting enabled the OnStateUpdate method is actually handled during FixedUpdate?

yes exactly, SMB need to be ticked in sync with the animator otherwise parameter passed to SMB wouldn’t make any sense

1 Like

Alright! No problems then

What if I want to use both FixedUpdate (for usual physics) and Update (for user-interface stuff)? Do I have to load another script, inheriting from MonoBehaviour and attach it the GameObject, and then unload it when exiting the state?

You can’t setup an animator in both update mode, it either: Normal, AnimatePhysic or Unscaled.

You need to use two different animator, one for the physic stuff and another one for your UI

3 Likes