playMaker

Author Topic: Rotate back and forth - Infinite loop  (Read 3664 times)

Abdou23

  • Playmaker Newbie
  • *
  • Posts: 30
Rotate back and forth - Infinite loop
« on: May 15, 2017, 04:38:51 PM »
So I'm trying to rotate an object back & forth. I have:
 1- A main state that goes directly to "Turn Right"
2- Then a "Turn Right" state that has:
     1- "Rotate" 10 on Y axis.
     2- "Get Rotation" stores the Y rotation on a variable "Y Rotation"
     3- "Float Compare" that compares if "Y Rotation" greater than 90. then it send an event to another state which is identical but does the opposite.
I keep getting this error:
" Loop count exceeded maximum: 1000 Default is 1000. Override in Fsm Inspector."
What am I doing wrong here? and/or what is the best way to rotate an object back and forth on a certain axis?

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
Re: Rotate back and forth - Infinite loop
« Reply #1 on: May 16, 2017, 07:00:04 PM »
Recap

state1
It does your rotate, get rotation, then float compare.  If everything aligns, then goto state 2

State2
It does your rotate, get rotation, then float compare.  If everything aligns, then goto state 1

Whats happening is its able to do everything in state1 then transition to state2 then transition to state1, so its an infinite loop.   

Quick way, use iTween Rotate To.  Set the vector rotation and then add a time like 2 seconds.  Use loop type = Ping Pong and it should do what you want.  By setting the time you are requesting that the rotate takes 2 seconds to complete.

Eventually you should transition to something like DoTween. 
  Its a bit more work to setup but much faster and less intensive tweening system.
 http://dotween.demigiant.com/download.php There are free actions and paid actions also listed on the site.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Rotate back and forth - Infinite loop
« Reply #2 on: May 17, 2017, 02:13:01 AM »
Hi,

 typically, your float comparision is wrong and basically it resulst in the two states constantly transiting, so I would simply pause Unity and step forwards to check the value you compare.

 Bye,

 Jean