playMaker

Author Topic: [solved] Will I get an infinite loop error for this?  (Read 1989 times)

createasaurus

  • Full Member
  • ***
  • Posts: 146
[solved] Will I get an infinite loop error for this?
« on: November 11, 2014, 05:39:13 PM »
I have StateA and StateB.  Each state contains, some commands and a Wait for .25 seconds then Finish.  StateA Finish leads to StateB.  StateB Finish leads to StateA.  It goes back and forth.  It runs great.  However, will this give me a problem later???  For instance if the game runs for 20 minutes or so and the back and forth reach a critical number, like 1000.  Will it then trigger infinite loop error?  Or am I safe?
Thank you for your thoughts!
« Last Edit: November 12, 2014, 03:08:48 AM by createasaurus »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Will I get an infinite loop error for this?
« Reply #1 on: November 11, 2014, 05:53:35 PM »
Infinite loops errors are triggered when they are uncontrolled like 1000x per second. In this case it's not happening fast enough to cause an issue.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Will I get an infinite loop error for this?
« Reply #2 on: November 11, 2014, 06:08:55 PM »
No, you're fine. You get infinite loop errors when you loop through the same states too many times in *one frame* It's trying to catch a loop that would otherwise hang or crash Unity. Instead of crashing, Playmaker breaks out of the loop and throws an error so you can investigate the cause... If you made the same infinite loop in a script it would crash Unity!

Your scenario is fine :)

There's an option in the Debug menu: Show State Loop Counts that can be useful when working with loops. It shows the number of times a state was entered this frame.

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Will I get an infinite loop error for this?
« Reply #3 on: November 12, 2014, 03:07:43 AM »
Excellent!  Thank you so much.  I will proceed as planned :D