Page 1 of 1

Unity Animator Problem

Posted: Mon May 21, 2018 10:48 am
by SiThu
Hi, I just testing Creature for our new 2d game. But i have one problem using with Animator in Unity. It doesn't change animation stage and stuck in animation stage set on CreatureRendener(scripts) --> Animation.

And I got this error,

"NullReferenceException: Object reference not set to an instance of an object
CreatureStateMachineBehavior.OnStateEnter (UnityEngine.Animator animator, AnimatorStateInfo stateInfo, Int32 layerIndex) (at Assets/Distro/CreatureStateMachineBehavior.cs:20)"

There are no other scripts in the unity project, just playing with demos and stuck in there :cry: Is there any thing i missed?

Re: Unity Animator Problem

Posted: Tue May 22, 2018 12:54 am
by chong
Hello,

I just checked with a test case using MecAnim and it seems to be running fine.
The error seems to indicate that some reference to an object is null. What is null in this case?
If you run this in Visual Studio, what does the inspector say during debugging? Which variable/property is null?

Re: Unity Animator Problem

Posted: Fri May 25, 2018 4:39 am
by SiThu
Sry Chong, i miss placed the animator to creature renderer instead of creature game controller. Now everything is Ok and i delete my old testing projects and Nullreference error gone too :D . Just want to ask one question, How can i change the speed of the animation stage? I just tried with local time scale and all the of animation stage speed change. I want to change the speed of the animation stage individually. :?

Re: Unity Animator Problem

Posted: Fri May 25, 2018 5:03 am
by chong
Hello,

There is no support in the Unity plugin UI yet, but you can modify the code to do this:
https://github.com/kestrelm/Creature_Un ... eModule.cs

Look at the function:

Code: Select all

private void IncreAutoBlendRunTimes(float delta_in)

In it, it increments the animation runtime ( frame ) for each blended animation. You can easily adapt this to have a custom increment delta time based on your animation name.