Health Problem?

Get help using Construct 2

Post » Wed May 08, 2013 3:55 am

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

if anyone could help me i would appreciate it heaps    
B
3
Posts: 3
Reputation: 181

Post » Wed May 08, 2013 4:31 am

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.
B
10
S
3
Posts: 102
Reputation: 1,888

Post » Wed May 08, 2013 5:50 am

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
B
3
Posts: 3
Reputation: 181

Post » Wed May 08, 2013 6:19 am

you have to reset the global variables as well
B
18
S
6
G
3
Posts: 197
Reputation: 4,129

Post » Wed May 08, 2013 7:03 am

thanks for the reply yonda, i didnt think of resetting the global variables it worked thanks

thanks for your help guys   
B
3
Posts: 3
Reputation: 181

Post » Wed May 08, 2013 7:27 pm

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.
B
17
S
4
G
4
Posts: 143
Reputation: 4,004

Post » Wed May 08, 2013 11:05 pm

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.
B
23
S
7
G
3
Posts: 180
Reputation: 4,064


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests