playMaker

Author Topic: "Animator has not been initialized" with PlayMaker Animator  (Read 10150 times)

karakumi

  • Playmaker Newbie
  • *
  • Posts: 2
Unity version: 4.1.2
PlayMaker: 1.5.7
Latest PlayMaker Animator package (current as of this writing)

I'm trying to drive Mecanim parameters via PlayMaker Animator, e.g. using the SetAnimatorInt action.  I'm currently blocked as SetAnimatorInt's OnEnter method emits the warning "Animator has not been initialized" when the _animator.SetInteger(...) call happens and the Mecanim parameter is not updated.

I created a standalone test script (i.e. a MonoBehavior) that acquires the GameObject's animator and calls SetInteger in the Start() method -- that works just fine.  So there's something specific to the action code that's problematic.  I've confirmed that I'm getting a non-null animator, that animator.avatar is non-null, and that animator.avatar.isValid is true, following on from triage advice in an old Unity Mecanim thread related to this error message.

This error occurs whether the SetAnimatorInt action is on the initial state, or on a state triggered later during gameplay.  Note that the error doesn't even involve the proxy code, as it's happening in OnEnter.  Nevertheless, I've tested the presence/absence of the proxy on the game object -- no change either way.

Any clues?  I've run out of ideas on this one.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: "Animator has not been initialized" with PlayMaker Animator
« Reply #1 on: May 14, 2013, 11:41:26 PM »
Hi,

 uhm, never encountred this while developing it.

http://forum.unity3d.com/threads/158874-Mecanim-issue-Animator-has-not-been-initialized

Apparently this is fixed in 4.1 so not sure why you are getting this still...

If you can share a repro project with me, that would be great.

bye,

 Jean

karakumi

  • Playmaker Newbie
  • *
  • Posts: 2
Re: "Animator has not been initialized" with PlayMaker Animator
« Reply #2 on: May 15, 2013, 05:26:56 PM »
Nailed it.  Here's some details on our setup, the apparent problem, and the resolution.

The Setup

  • Add an empty game object to the scene as a "container".
  • Add a character model with animations (I used a Blender model from our art team) as a child of the container object.
  • Add a Mecanim Animator component to the character model object.
  • Create a simple Mecanim state machine triggered by an Int parameter (e.g. a "State" parameter).
  • Add a PlayMaker FSM to the model object
  • Setup a simple PlayMaker state machine (e.g. game states that will be linked to animation state changes)
  • Add a SetAnimatorInt action to the PlayMaker FSM
  • Set the "Parameter" and "Value" settings based on your Mecanim FSM setup in step 4, above.
  • Change SetAnimatorInt's parameters: set "Game Object" to "Specify Game Object" then choose the model object as the target.

The Problem

I'd originally setup the PlayMaker FSM on the empty container object created in step 1, then tried to target the Animator attached to the contained character model object.  This produced the "Animator has not been initialized" error.  I later moved the PlayMaker FSM to the model object, but still received the same error.

The Resolution

Only once the PlayMaker FSM was attached to the model and the SetAnimatorInt action was changed to use "Use Owner" as its game object did the action stop emitting the error and work as expected.

So it appears that we've been hitting this problem any time we explicitly specify a game object for SetAnimatorInt rather than "Use Owner".

Jean, let me know the above is enough to illuminate the problem.  Otherwise I can try to create a mini-project that reproduces it.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: "Animator has not been initialized" with PlayMaker Animator
« Reply #3 on: May 16, 2013, 02:41:58 PM »
Hi,

 thanks for the clear explanations, however It seems to work here, I can access and set animator params on other gameObjects, not just when using "owner" I could do with a repro project for sure, it might be something with the animator state machine set up itself or when and how the call is performed.

bye,

 Jean