<b>Question:</b> "Basically, I have 4 objects on the screen and I want each instance to have its own health.
Thanks for any tips
Keith"
<b>Answer:</b> the built in health variable is just like any other global variable, but as it is global you won't be able to use it for four objects. Therefore you must create a local variable. A local variable is any variable which is not built in, and not predefined as a constant, or intialized as a global variable. A global variable which is not built in typically looks like this: global.variable, but normal variables is just a word... so in the create event of each object you say:
my_health = 100;
This will work as the built in variable health, with one exception. To subtract health from a specific object you must adress the change to that certain object. If you for an example want to subtract the health by five from obj_bullet, then in obj_bullet you write object_character1.my_health -=5; instead of just my_health-=5.
I hope you understand, just reply (by commenting) if you have any problems.
.
Users logged in:
Comments
Loading comments...