playMaker

Author Topic: Get Animator Current State Info Action issue  (Read 5935 times)

oxyscythe

  • Playmaker Newbie
  • *
  • Posts: 5
Get Animator Current State Info Action issue
« on: December 13, 2014, 05:10:58 PM »
Hello,

I just started using PlayMaker and have been really impressed by both how easy it is to learn and by how much it speeds up my workflow by letting me visually implement features that would take a lot longer to do via code.

I've also just encountered my first issue, which is to do with the Get Animator Current State Info action.

I can't get it to return valid data. It seems to return just "Base Layer" for the name of the state and 0.06667 for the length of the animation. Almost as if it thinks there's no animation state currently active?

I've got an Animator SetTrigger action right before the Get Current State Info action so I am definitely triggering a (lengthy) animation, which does actually play, it's just that the Get Current State Info action won't actually return any valid data.

Is this a known issue? Am I doing something wrong?

What I am trying to do is retrieve the length of the currently playing animation so I can feed it into a Wait action and ensure my FSM will remain in the current state for as long as the animation keeps playing.

Thanks!


PS: While I am here I'll sneak in another question. I just realised that Wait won't actually suspend the execution of the action list in the state, all it does is it suspends the firing of the FINISHED event. Is there an alternative to Wait that will actually suspend the execution of the action list where the Wait is?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Get Animator Current State Info Action issue
« Reply #1 on: December 13, 2014, 11:30:18 PM »
I'll let Jean reply to the Animator question, but I can answer the Wait question.

In the State settings menu (the gear icon next to the state name and color) there is an Action Sequence setting. This setting tells the state to run each action to completion before executing the next action. In an Action Sequence a Wait would delay the execution of the next action...

Alternatively you can make a Wait state with a Wait action and a transition to the next state on FINISHED.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Animator Current State Info Action issue
« Reply #2 on: December 16, 2014, 02:48:20 AM »
Hi,

 yeah, something is fishy here. If you can pm me with a package I can study, then I'll be able to see if it's a setup issue of indeed something wrong internally.

 Tho, you may be interested in using my new mirror proxy that matches animator states and transition with PlayMaker Fsm. which basically will totally remove the need to manually check animations.



Bye,

 Jean

oxyscythe

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Get Animator Current State Info Action issue
« Reply #3 on: January 06, 2015, 08:43:31 AM »
Hello!

Sorry for taking ages to respond to this, combination of personal stuff and holidays meant I took a long break from this project and I am only just getting back into it.

Right, so first off, Alex, thanks for the WAIT and Action Sequence tip, that was exactly what I was after and it's working a charm.

Jean, so I spent some time putting together a small test project in an effort to isolate the issue for you and frustratingly (?) it's not happening in the test project! Get Animator State Info seems to be returning the valid length for the currently playing animation.

So I am going to go back to the full project and make sure I am not doing anything silly.

In the meantime there's another relevant thing I wanted to point out which is that I am getting a compile time error in the Mecanim stuff since upgrading Unity to 4.6.1.f1

The error is this:

Assets/PlayMaker Animator/Actions/GetAnimatorIsControlled.cs(94,56): error CS0619: `UnityEngine.Animator.IsControlled(UnityEngine.Transform)' is obsolete: `use mask and layers to control subset of transfroms in a skeleton'


I've commented this function out for now.

Just to make sure I am doing things correctly: I've downloaded the PlayMaker/Mecanim stuff from this page:

https://hutonggames.fogbugz.com/?W1031

Is this the right process? Will the latest mecanim/playmaker be found on that page? I was wondering how come this stuff is not included in the base playmaker package?

Jean the mirror proxy stuff you mentioned definitely sounds very interesting. All I am trying to do is make sure the animator and the playmaker fsm are in sync (it doesn't always matter but in the cases where it does it can cause problems when they're not) and checking every time manually and doing a wait action to force them to be in sync can get a bit tedious. So if you have a better way I am all ears! :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Animator Current State Info Action issue
« Reply #4 on: January 07, 2015, 04:24:55 AM »
Hi,

 Yeah, I just published a new package on the mecanim wiki page to comply with Unity 4.6.1. The quick fix is to delete that 'GetAnimatorIsControlled' action and you are good to go.

yes, the proxy to synch states between animator and playmaker is definitly the right thing for you, have you experiemented with it so far?

 Bye,

 Jean

oxyscythe

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Get Animator Current State Info Action issue
« Reply #5 on: January 07, 2015, 12:31:35 PM »
Great, thanks Jean, I grabbed the latest version and integrated it into my project already. No errors now.

I have not experimented with the proxy. Not sure where to find it?

Btw, weirdly enough the Get Current Animator State Info issue came back for me with the exact same combination of NPC and FSM as before (which is super weird as I redid pretty much everything and, like I said in previous posts, it now works fine for other NPCs/FSMs). I've hardcoded the wait time for now as I don't really want to redo the FSM and I can't see anything obviously wrong with it, but if the proxy approach works better I might try that as I really dislike having this hardcoding hack in there.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Animator Current State Info Action issue
« Reply #6 on: January 08, 2015, 09:06:23 AM »
Hi,

 The proxy is called "PlayMakerAnimatorStateSynchronization",

full thread here

 Bye,

 Jean

oxyscythe

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Get Animator Current State Info Action issue
« Reply #7 on: February 26, 2015, 02:01:04 PM »
Hi Jean,

Me again with a super delayed reply (again!)

First of all thanks for the links to the proxy component. That looks super cool indeed and in most cases it'd be something that I would definitely be using (are Unity doing some similar stuff in the new Mecanim? I think I saw something along those lines in a Unity 5 video)


Now, in this particular case I kinda need to be manually fetching the animation length from the animator, so I do need to be using the Get Current Animator State Info action. This is because my state machine is actually on a different gameobject than the animator (or more precisely my state machine is meant to control flow based on what various different animators in the scene are doing). So the proxy is no good for me.


Moreover, I did manage to reproduce the issue I am continuing to have in a small test scene (woohoo!)

So I've sent you a PM with the test project so you can take a look.

Just to explain I have 3 dummy "Cutscene" gameobjects in that scene and then I have a "FlowControl" game object that has an FSM on it. FlowControl is meant to be getting Animator State information from the 3 cutscene game objects so that it can advance the flow appropriately (if you look at the actions in each state of FlowControl it should be self explanatory)

What seems to be happening is that Get Current Animator State Info is not actually fetching the right Animation State for some reason. In fact when I use a Debug Log String action to output the Name of the currently playing animation, it always just says "Base Layer" instead of "Base Layer.SomeAnimation" which is what I would expect. And of course the Length parameter always returns 0 (which is the main issue)

I'd be really grateful if you could figure out what's going on here as I spent hours today trying to get it to work, but I feel I've reached the limit of my debugging ability.

Many thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Animator Current State Info Action issue
« Reply #8 on: March 03, 2015, 12:58:23 AM »
Hi,

 yep, I was confronted with this, the way they do it in script is to actuall check for the name of the state, and not rely on this current state info.

so I use "Get Animator Current State Info Is Name" and that will allow you to know exactly where you are by explicitly requesting a name comparision.

 have you checked out the mecanim samples on the wiki, they will demonstrate how it's done.

 Bye,

 Jean