playMaker

Author Topic: Animator State Sync issue.  (Read 2221 times)

Doh

  • Full Member
  • ***
  • Posts: 124
Animator State Sync issue.
« on: November 19, 2017, 09:32:09 AM »
Hey, I'm having an issue I can't seem to fix using the Animator State Synchronization script.

The setup is pretty straight forward, I have an animator with 4 states that form a simple 4 stage loop. I have an FSM on another object that has 5 states, each named appropriately. The 5th state is a transition between two of the animations.

The whole thing functions correctly in sync for the 1st cycle, then on the second time around the transition state is not synchronized.

Has anybody come across a similar issue recently? Any help on this issue would be greatly appreciated!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Animator State Sync issue.
« Reply #1 on: November 19, 2017, 05:27:52 PM »
Hi,
If you use 4 states does it work as supposed to?
If so maybe you should make the 2 state event in a different fsm and use a send event from the synced fsm

Doh

  • Full Member
  • ***
  • Posts: 124
Re: Animator State Sync issue.
« Reply #2 on: November 19, 2017, 08:20:04 PM »
Cheers for the suggestion djaydino, I've attached an image of the animator and the FSM to help illustrate the issue.

In the image of the animator I've highlighted the transition that is named "Scan to Scan Shutdown".

The part that baffles me is that it works on the first time round but not any time after that.

As you can see "Scan Off" is the entry state where it stays idle until a different FSM (not pictured here) sets the animation trigger "Scan_Activation", then the animation "Scan Startup" plays and then "Scan" loops until the FSM (the one not shown in the images) sets another animation trigger "Scan_Deactivation" which begins the transition "Scan to Scan Shutdown" then the animation "Scan Shutdown" follows and once complete it returns to the "Scan Off" animation.

As I say this works perfectly on the first cycle, then on the second loop it syncs everything but the "Scan to Scan Shutdown" transition.

Is this normal behavior, that it only works on a single cycle through the animations or have I miss-used it?

And in answer to your question yes with only 4 states it does work as you'd expect, however I have an animation on another object that relies on knowing when the transition begins rather that when the next animation finally begins. Regardless of that though each state currently gives a valuable instruction to elements of the game, so I'd struggle without the transition sync state.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Animator State Sync issue.
« Reply #3 on: November 20, 2017, 05:09:46 PM »
Hi,
I believe that you can achieve this by making a state and name it with the 2 animator states and add 'to' in between (so "state1 to state2")

Doh

  • Full Member
  • ***
  • Posts: 124
Re: Animator State Sync issue.
« Reply #4 on: November 20, 2017, 08:29:24 PM »
That's what I currently have, in my case it's "Scan to Scan Shutdown" as the transition is from the animation "Scan" into "Scan Shutdown". This is the same method shown in the youtube tutorial made by Jeanfabre. It seems more like I've hit a bug as it functions correctly on the first cycle.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Animator State Sync issue.
« Reply #5 on: November 21, 2017, 11:32:14 AM »
Hi,
I guess the video is outdated "to" does not work anymore instead use "->"

But i wonder that you are getting a first cycle, i did not get any cycle for the "between" states when using 'to'

Doh

  • Full Member
  • ***
  • Posts: 124
Re: Animator State Sync issue.
« Reply #6 on: November 21, 2017, 04:13:10 PM »
I renamed the transition to include the word "to", I'll try your suggestion first thing tomorrow and get back to you with the results.

Cheers again!

Doh

  • Full Member
  • ***
  • Posts: 124
Re: Animator State Sync issue.
« Reply #7 on: November 22, 2017, 11:27:34 AM »
"->" is the current method, cheers for that! Though the problem is still occurring where the first cycle works correctly then it ignores the transition beyond that point.

Doh

  • Full Member
  • ***
  • Posts: 124
Re: Animator State Sync issue.
« Reply #8 on: November 22, 2017, 12:18:50 PM »
I've worked out how to make it cycle without failing. Though it means borking my animations a bit.

The only animation that has a transition duration is the "Scan -> Scan Shutdown" transition. If I make it so at least one other transition has a duration then it cycles endlessly without fail.

My guess is that when the sync script checks lastTransition against _currentTransition (and only one transition has a duration) it thinks the animator hasn't progressed since the first cycle.

Is it possible that the script could be updated to take the single transition duration scenario into account? I can get by without it this time but I can see this coming up again in the future.
« Last Edit: November 22, 2017, 12:20:26 PM by Doh »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Animator State Sync issue.
« Reply #9 on: November 23, 2017, 03:41:08 AM »
Hi,
Maybe instead of a state sync you could use a animation event?


Doh

  • Full Member
  • ***
  • Posts: 124
Re: Animator State Sync issue.
« Reply #10 on: November 23, 2017, 08:19:20 AM »
Good call, though I'm sticking with the sync script as the most simple solution for my setup, to use animation events I'd have to introduce more global events, an event proxy and rearrange various FSMs that currently rely on the states synced by the script.

All I had to do this way was make sure there was more than one transition that had a duration.