0
Fixed

Animator and Unity Message Listener Script

DarkNBlood 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 5

Hi,

I've my character with an Animator component. Apply root motion is active due to my animations. For example, I move my character for a normal C# script using :

Animator.SetFloat("velocityY", input.GetAxis("Vertical"));

All is working fine with my script, the animation is played and my character move according the animation.


Trying with Bolt, I've a StateMachine and a state with conversion of the C# script in Update. In play mode, my character don't move but the animation is played !

If while in play mode, I remove Unity Listener Script component, who is added by Bolt in runtime, all is working fine, my character move according to animation :/

Thanks for help.

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

Oh I missed, I'm with Bolt 1.4 Beta 2, same problem with 1.4 Beta 1...

Working on Fix

Interesting problem. It seems that adding a handler for OnAnimatorMove or OnAnimatorIK disables Unity's default handling of it. I might have to create them as separate components, which is annoying... I'll look into the simplest fix.

+3
Fixed in Beta

Indeed, it seems that Unity disables all motion and collision code handling usually done by the animator if the game object has a MonoBehaviour with an OnAnimatorMove or OnAnimatorIK movement. This is entirely undocumented, but other people have had similar issues:

The problem is that Bolt needs to register these messages in its message listener component to be able to forward them to the graph, in case a user wants to override them manually. They were added in v.1.4.0 for this reason.

The only solution I can think of is creating a new, separate component that handles specifically these two messages. I call it Animator Message Listener and it will be located under Bolt / Listeners.


If you add this component to your game object, On Animator Move and On Animator IK will be overridden by Bolt and forwarded to your graphs. It is your responsibility to handle root motion code then.

As suggested by one of the users in the Unity forums, a simple way to preserve the default root motion behavior would be to do something like this:

This fix will be implemented in Beta 3 or stable.

Thanks, that's working fine while waiting fix ;)