Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

OnStateUpdate Not Working in Build Mode

Discussion in 'Scripting' started by JungaBoon, Dec 14, 2020.

  1. JungaBoon

    JungaBoon

    Joined:
    Aug 4, 2020
    Posts:
    17
    I have a fairly simple rotate script in an object's OnStateUpdate:

    Code (CSharp):
    1.     override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    2.     {
    3.         Vector3 direction = player.transform.position - wheelBot.transform.position;
    4.         direction.y = 0;
    5.  
    6.         wheelBot.transform.rotation = Quaternion.Slerp(wheelBot.transform.rotation, Quaternion.LookRotation(direction), 0.1f);
    7.     }
    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.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    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.
     
  3. JungaBoon

    JungaBoon

    Joined:
    Aug 4, 2020
    Posts:
    17
    Hi, how can I see a log of my build?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847