- Home /
Transform rotation animation no longer works with version 5
A few days ago I decided to start playing around in unity3d and started a new project in version 4, after getting things the way I liked them I noticed version 5 had been released so I downloaded and upgraded it.
I had built a simple 2d sprite and wrote a player controller script in C# using a rigidbody (not rigidbody2D) and 2d sprite renderer. From there I have a animation state machine that sets the sprite in the 2d sprite renderer based on raw horizontal and vertical axis input to face the character in the correct direction. From that state I check if the axis is still pressed in that direction and go to a state that has an animation that rotates the transform of the object to create a southpark style jerky walk animation, In version 4 this works just fine, theirs a link below that shows it in action. In version 5 this no longer works for some reason, when I upgraded my project I had to redo my state machine, which wasn't too surprising. I set it back up exactly the same way and everything works as expected except the transform animation which does not play at all during run time, it does work if I open the animation window and play the keyframes outside of the runtime however.
This error also spams in my log on game start.
NullReferenceException: Object reference not set to an instance of an object
at UnityEditor.Graphs.AnimationStateMachine.TransitionEditionContext.BuildNames () [0x00095] in C:\buildslave\unity\build\Editor\Graphs\UnityEditor.Graphs\AnimationStateMachine\TransitionEditionContext.cs:44
at UnityEditor.Graphs.AnimationStateMachine.TransitionEditionContext..ctor (UnityEditor.Animations.AnimatorTransitionBase aTransition, UnityEditor.Animations.AnimatorState aSourceState, UnityEditor.Animations.AnimatorStateMachine aSourceStateMachine, UnityEditor.Animations.AnimatorStateMachine aOwnerStateMachine) [0x00023] in C:\buildslave\unity\build\Editor\Graphs\UnityEditor.Graphs\AnimationStateMachine\TransitionEditionContext.cs:28
at UnityEditor.Graphs.AnimationStateMachine.AnimatorTransitionInspectorBase.ComputeTransitionContexts () [0x00068] in C:\buildslave\unity\build\Editor\Graphs\UnityEditor.Graphs\AnimationStateMachine\AnimatorTransitionInspectorBase.cs:125
at UnityEditor.Graphs.AnimationStateMachine.AnimatorTransitionInspectorBase.OnEnable () [0x00183] in C:\buildslave\unity\build\Editor\Graphs\UnityEditor.Graphs\AnimationStateMachine\AnimatorTransitionInspectorBase.cs:87
at UnityEditor.Graphs.AnimationStateMachine.AnimatorStateTransitionInspector.OnEnable () [0x00000] in C:\buildslave\unity\build\Editor\Graphs\UnityEditor.Graphs\AnimationStateMachine\AnimatorStateTransitionInspector.cs:55
I have a webplayer runtime I compiled before updating to 5 if you'd like to see how the animation should look.
http://dl.dropboxusercontent.com/u/79418017/tinyterror/gametest.html (wasd for movement)
I'm guessing the issue is partially due to the reworked physics in version 5 since my speed/force values needed to be changed as well for rigidbody.addForce, or is this due to something else? I'd also like to know if this is even the right way to control a 2d object in 3d space (I'd use a rigidbody2d but I need to be able to move on all 3 axis) should I be using a different method to animate the character for the walk cycle? animating the transform of an object with a rigidbody seemed like kind of a hacky way to do it and I'm not sure if I should use 2d sprites for something like this. Is there a better method to have a 2d player in a 3d world? I'd use a plane but it doesn't support sprite sheets, and on top of that it results in a lot of adjustment to remove stretching the texture.
Your answer
Follow this Question
Related Questions
Transform rotation animation no longer works with version 5 0 Answers
Animation Event and Sate Machine Behaviour 0 Answers
Detecting last frame of animation, without StateMachineBehaviours or Animation Events 0 Answers
Can StateMachineBehaviour use root transform? 1 Answer
Some parts of animation not playing 0 Answers