Error on checking variables

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Right now in my game I have a variable that when PHealth is 0 or less subtract 1 from lives and reset health to 10, For some reason it subtract 1 from lives and reset the health total but wont stop subtracting from lives. I can seem to stop it. Can someone take a look and see where my error is. Also to skip around the game 1 takes you to first level, 2 to second level and 3 to last level.   Thank you. I am also still having trouble with enemies all trying to attack me when one finds me instead of just the one within range.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You did not post a capx, so hard to look at anything.

    Nevertheless from what you describe, you have an event with a condition PHealth <= 0.

    When this event executes it acts on the values of some variables.

    You say you reset Health to 10.

    But the variable PHealth is still <= 0. So the next tick, when C2 test this condition, it will be true again and so the event executes again, etc...

    What you need is, in this very event, to set PHealth to a different value than 0. As last action, set PHealth to 10 and you'll be sure that the very tick the event executes since its condition is true, an action makes it so that the next tick the condition will be false and the event won't execute again.

  • whoops. I Thought I did.Game I am having both Health and Phealth resetting to 10. Maybe I missed something. Also is there a way to set an enemy to move on walls.

  • Any ideas?

  • I still can't figure out the issue.

  • The problem is that the event sheet is run every tick. In the condition where the Player.PHealth <= 0, you're waiting 1.5 seconds and then 0.3 seconds. While it's waiting, the event sheet is running again and again and continuously subtracting 1 from lives.

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