How do I fix this looping error?

1 favourites
  • 4 posts
From the Asset Store
7 Errors
$15 USD
7 Errors is a game where you have to find the 7 mistakes before time runs out. Can you find all 7? Have fun looking.
  • Hi so I'm trying to make a pokemon style game with turn-based combat. Line 11 checks to see if an instance variable "EnemyTurn" is true, and if so then line 12 will apply damage to the Player ONCE while "EnemyTurn" is true, and line 13 will set "EnemyTurn" to false if the Player's HP is greater than 0.

    The PROBLEM is that, occasionally, the damage will be applied around 4-6 times in a second even though it should only be applied once. Somehow the "EnemyTurn" variable is being set to true multiple times in a second? Please help not sure what I'm doing wrong.

  • At first glance, it looks like it's due to the 3 second wait you have before setting enemyturn to false. If the player's hp is greater than 0,enemyturn is true for three seconds until you set it to false. During that time, all of these events will run. I'd try disabling the wait actions and see what happens.

  • Thank you for your suggestion. It didn't end up working but I did find the solution after some more tinkering!

    I grouped lines 12 and 13 separately from line 11. I still checked to see if "EnemyTurn" was true and used the "System: Trigger Once" condition again. I also found that the order you place the "System: Trigger Once" condition is important: the loop kept breaking when it was above "Game...:Is EnemyTurn", but then worked fine once it was below it.

    Anyways, thank you again for the suggestion!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah, as brushfe mentioned, event 11 is executed on every tick while EnemyTurn is true, about 60 times per second. And because you have "Waits" inside of it, it created hundreds of delayed threads. You should avoid these things.

    Besides, "Trigger once" should not be used on its own. You need to move "Trigger once" from event 12 to event 11 (as a second condition).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)