- Home /
Why, when I delete transitions from the Animator State Machine, do I get a null reference exception?
After I have edited my animation state machine in the Animator Controller, I often get the following bug when playing my game. I think it is related to me deleting transitions from the animation state machine, but I can not get the bug to go away.
NullReferenceException: Object reference not set to an instance of an object UnityEditor.Graphs.AnimationStateMachine.TransitionInspector.OnEnable () (at /Applications/buildAgent/work/812c4f5049264fad/Editor/Graphs/UnityEditor.Graphs/AnimationStateMachine/TransitionInspector.cs:70)
Thanks!
I do not have any scripts referring to those deleted transitions or states. I only have 3 lines of script:
animator = GetComponent. . . .;Also, my animations are working correctly.
animator.SetFloat("V_Axis", Input.GetAxis("Vertical"));
animator.SetFloat("H_Axis", Input.GetAxis("Horizontal"));
Answer by BrandonBradley · Feb 14, 2013 at 08:28 PM
I was getting this issue as well. I tried removing the Animation Controllers and recreating them (without ever creating any transitions). I applied the new controllers to my characters, but was still seeing this error.
What finally resolved it was to save my file, shut down Unity and then relaunch it. It seems the reference was cached in the IDE, and restarting allowed it to be cleared.
Worked. $$anonymous$$ecanim animation editor seems to have a few other serialization issues... I was getting an m_Active bool error for the longest time from a param I added as a bool, removed, then added as a float before saving. Until I removed it, saved, closed, reopened, readded as just a float did it work. This is on a project upgraded from 4.2 to 4.3 so maybe a conversion issue. I save scene and project frequently due to prefab work but only shutting down fixed this null reference animation controller issue.
Had the same issue, Unity 4.3.4. Only restart of Unity helped. Anyone reported a bug?
Same issue with 4.3.4. When messing with the Animation Controller and saving it, playing gives a random error in one of my GUI scripts (there are 0 actual errors with this small script). I commented those lines out and it gives only the error above. Restarting Unity fixes it, but then when changing the Animation Controller it bugs out again, requiring a restart.
$$anonymous$$y project was also upgraded from an older Unity version. Has anyone submitted a project to Unity bugs?
I have the same issue with 5.1. Restart of unity and the computer did not work as well. Any recomendation?
Answer by Doireth · Jan 31, 2013 at 04:25 PM
The line:
animator = GetComponent();
Is your problem. The "GetComponent" call requires a component type to get. For example:
animator = GetComponent(Animator);
No. I simply could not get the less than sign to show up in the forum post editor. This is not related to my Unity problem.
Have you tried double-clicking on the error message in the editor console and see where it directs you?
It directs me to: Editor/Graphs/UnityEditor.Graphs/AnimationState$$anonymous$$achine/TransitionInspector.cs:70)
i.e. Not my code, but Unity's.
Without more information about your state machines and how your script relates to it, there's little I can do to help.
I can happily send you everything as it is basically a tutorial project with Unity tutorial assets. How do I send it?
Answer by percival49 · Jun 17, 2017 at 03:29 PM
What I did was I delete all the metadata in the assets folder library/metadata. That problem triggers when I untick the animator exit time, it throws the nullreferenceexception, I found restarting is a solution but the better way is deleting the metadata and then poof! The bug is gone.