OnStateUpdate Not Working in Build Mode

I have a fairly simple rotate script in an object’s OnStateUpdate:

    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Vector3 direction = player.transform.position - wheelBot.transform.position;
        direction.y = 0;

        wheelBot.transform.rotation = Quaternion.Slerp(wheelBot.transform.rotation, Quaternion.LookRotation(direction), 0.1f);
    }

When I run it in the Editor, it runs fine. The object rotates towards the player as intended. But when I Build it out and run it, the object simply won’t rotate.

Some things to note:

  • I’m Building it out to Windows x86
  • The animations I’m using on the object are using Root Motion
  • No errors are appearing in the Log when I run in the Editor

I would appreciate any idea as to why the rotation won’t work in the Build version. Thanks.

The problem is happing when running your build, so the log you need to be looking at is the one when running your build. Also add some Debug.Log statements to verify that this method is being called, and what values it is assigning.

Hi, how can I see a log of my build?

See the “Player” section
https://docs.unity3d.com/2019.3/Documentation/Manual/LogFiles.html