Page 1 of 1

Health Noobie question

PostPosted: Mon Dec 04, 2006 7:44 am
by S0L1Dfake
I am a noob to GE and I just started putting together some elements to a game and I am running into a problem. I set variable "health" to 5, then have a collision event "health = health - 1;" then an item that when collision occurs adds "health = health + 1;" but for some reason it automatically raises it to 6, or so i think. Am I making some common mistake or what? and how do I display the value of a variable (ie, "health") on the game screen?

PostPosted: Mon Dec 04, 2006 9:41 am
by Novice
Don't double post.

PostPosted: Mon Dec 04, 2006 12:33 pm
by makslane
The add action happens before de sub action.
To see the variable value, create a text actor and put a Draw Actor event with the code:

textNumber = health; //Or player.health if health is an Actor variable

PostPosted: Mon Dec 04, 2006 9:38 pm
by S0L1Dfake
Thank you makslane. I figured it out. I was putting the "health = health - 1;" action on the player when he collides with the enemy, and the "health = health +1;" command on the object when the player collides with it. So I just moved the command to the player and its fixed.