playMaker

Author Topic: When using Float Compare, I get loop count error...  (Read 5829 times)

Adam Z

  • Full Member
  • ***
  • Posts: 207
When using Float Compare, I get loop count error...
« on: March 09, 2016, 03:48:28 PM »
I get this error:
"Woman : Rotation : Loop count exceeded maximum: 1000 Default is 1000. Override in Fsm Inspector."

What I'm trying to do is go to another State if my X and Z floats changes from 0 when the payer uses the input keys. 

When the character is idle, the FSM plays correctly.  As soon as I hit the movement key, the Transition moves to the other State like it should, but then crashes. What am I missing?

Thanks.


« Last Edit: March 09, 2016, 03:54:17 PM by Adam Z »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: When using Float Compare, I get loop count error...
« Reply #1 on: March 09, 2016, 07:49:53 PM »
Hi,
you can try to add a state in between and add the action "Next Frame Event"

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: When using Float Compare, I get loop count error...
« Reply #2 on: March 10, 2016, 12:04:23 PM »
Hi,

From my noob experience, the fsm looks ok.

I guess it may help to know how you set the animator float, that you are getting (if you could post screens of that fsm).

As the float compare seems correct, so it must be to do with the float not being persistently above/below 0

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: When using Float Compare, I get loop count error...
« Reply #3 on: March 10, 2016, 12:40:18 PM »
Hi,
I was looking to your pictures again and i think you might be able to use the
PlayMakerAnimatorStateSynchronization component to do what  you are trying to do.


Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: When using Float Compare, I get loop count error...
« Reply #4 on: March 10, 2016, 01:39:31 PM »
Hi,
you can try to add a state in between and add the action "Next Frame Event"

I did this and it does work, however it seems to keep looping through all 4 states every frame, instead of just staying on the Character Moving State.

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: When using Float Compare, I get loop count error...
« Reply #5 on: March 10, 2016, 01:42:37 PM »
Hi,

From my noob experience, the fsm looks ok.

I guess it may help to know how you set the animator float, that you are getting (if you could post screens of that fsm).

As the float compare seems correct, so it must be to do with the float not being persistently above/below 0

The Animator Float should be in the screenshots within my 1st post.  All I'm doing is getting the float variable from my Movement FSM.

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: When using Float Compare, I get loop count error...
« Reply #6 on: March 10, 2016, 01:55:14 PM »
I know, thats what i meant, maybe post pics of the movement fsm. Im thinkig that, if it isnt a more technical issue, then it may be that the problem is with the actual setting of the float.

Im a noob though so all i say may be wrong...

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: When using Float Compare, I get loop count error...
« Reply #7 on: March 10, 2016, 02:08:12 PM »
I know, thats what i meant, maybe post pics of the movement fsm. Im thinkig that, if it isnt a more technical issue, then it may be that the problem is with the actual setting of the float.

Im a noob though so all i say may be wrong...

I appreciate your help. Here is a pic of my Movement FSM. Nothing fancy is going on, it's just storing if the mouse keys are pressed, and then telling the Animator to play the appropriate Root Motion animation based on that...

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: When using Float Compare, I get loop count error...
« Reply #8 on: March 10, 2016, 04:18:37 PM »
Yeah,  sadly im not much help lol.

Also youre right the movement fsm looks very straightforward.

I guess that leaves me wondering what is the last action in the 'is moving' and idle states (it looks likethe states have one more action following float compare- I may be wrong).

Could it be something that forces the float to be 0 or for the state to end?

Also, just brainstorming in case it never works this way:

Maybe add a 'wait' sonewhere in the is moving state. Either at the start or after get float.

More brainstorming and im just a noob so it may be something i totally dont understand, but would it be possible to achieve your goal by just 'get axis' again instead of the get animator float - or get fsm variable and get the float you saved the axis to originally (in the movement fsm), rather than the animator float.

Hope it helps and sorry to spam your topic otherwise. Good luck with it!

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: When using Float Compare, I get loop count error...
« Reply #9 on: March 10, 2016, 05:05:33 PM »
Well it seems that there's something wrong with having Float Compares on two different States in a row. I've tested each Float Compare individually, and they both execute the transition. As soon as I have them back-to-back on States, I get the crash with the loop error. 

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: When using Float Compare, I get loop count error...
« Reply #10 on: March 11, 2016, 01:34:08 AM »
Hi,
If you are using the animator i would go for the PlayMakerAnimatorStateSynchronization

Else you can try to play arround with the tolerance, try setting it to 0.1 on the moving state.

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: When using Float Compare, I get loop count error...
« Reply #11 on: March 11, 2016, 10:17:32 AM »
Hi,
If you are using the animator i would go for the PlayMakerAnimatorStateSynchronization

Else you can try to play arround with the tolerance, try setting it to 0.1 on the moving state.

I decided to not use the Animator, and use a Get Fsm Float instead.

To give you an idea of what I'm doing... I have an FSM on my character called Movement which detects input and sends that to the Animation Controller.

I have another FSM called Rotation on my character. So when my character isn't moving and I move the mouse, my Character rotates and also plays a stepping in place animation. As soon as he moves I need to de-activate that stepping in place animation, thus comparing the input floats to transition to another State. 

So using a tolerance will not work since the character can move back and strafe, thus creating a negative float number.

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: When using Float Compare, I get loop count error...
« Reply #12 on: March 11, 2016, 10:47:21 AM »
I even tried to put this on my Movement FSM, going from an Idle State to a Movement State... still doesn't work.

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: When using Float Compare, I get loop count error...
« Reply #13 on: March 11, 2016, 10:50:20 AM »
Im assuming this is correct, right? (This is the FloatCompare.cs script):

if (Mathf.Abs(float1.Value - float2.Value) <= tolerance.Value)
         {
            Fsm.Event(equal);
            return;
         }

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: When using Float Compare, I get loop count error...
« Reply #14 on: March 11, 2016, 01:55:25 PM »
Hi,
Maybe you should store your get axis variable into a global and use that global to set the animator float and also to compare.

Instead of setting the animator float and getting it again to compare.
I can not test this now but i think that will help.