Health Problem?

0 favourites
  • 7 posts
From the Asset Store
Custom animated Health Bar - check youtube video to make it yourself
  • hi, i've decided to create a game making Construct 2. i'm having problems with the health system for the player though, i want it so if it hits a wall then it takes off health, and if it hits 3 times then you die and restart the level.

    i have a Global Variable for health set to 8 and when the player collides with the walls it subtracts 2 from the health

    i also have a compare variable when the health is = to 0 it restarts the layout

    but when ever the player hits the wall they die almost instantly and it either continues playing the level with 0 health or it freezes. i've tried looking for health tutorials but can't seem to find the problem <img src="smileys/smiley19.gif" border="0" align="middle" />

    if anyone could help me i would appreciate it heaps <img src="smileys/smiley1.gif" border="0" align="middle" />   <img src="smileys/smiley17.gif" border="0" align="middle" />

  • It sounds like what the problem is you have the game subtract health "when overlapping the wall?" as opposed to "on collision with the wall?" The game rapidly constinues to subtract health in the blink of an eye cause the player is still "overlapping" the wall. But if it tests for "on collision", it should only take a hit once even if the player is standing by the wall. The player will then have to break contact with the wall and "collide" again to trigger more health loss. Also, you don't need a compare variable to determine if health is equal to zero. Just compare your global "health" variable directly to zero, not to another variable that is equal to zero cause that's redundant.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • hi farmerdwight thanks for the reply

    i have the player set to on collision with wall, and they cannot go through the wall they can only touch it

    i also made a lose screen, to test if it would work - the player hits the walls and after 4 hits it loaded the lose screen no problem - i added a button on that screen so the player could restart the level but when you click retry the level flashs for a second and it goes back to the load screen. i'm not sure what the problem with the level is <img src="smileys/smiley11.gif" border="0" align="middle" /> <img src="smileys/smiley11.gif" border="0" align="middle" />

  • you have to reset the global variables as well

  • thanks for the reply yonda, i didnt think of resetting the global variables <img src="smileys/smiley5.gif" border="0" align="middle" /> it worked thanks

    thanks for your help guys   <img src="smileys/smiley36.gif" border="0" align="middle" />

  • One more thing - you should have your death condition be health <= 0. This way, if health goes below 0 (say you add an extra dangerous wall that deals 3 damage), the game will still reset.

  • I can't tell from the replies here if the initial problem was solved or not, but one way to make absolutely sure it only damages you once per collision is to add a Trigger Once system condition.

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