Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Please try to make a player health counter. Also the bullet counter, after which the player'll not be able to shoot |
||||
|
Alright I think I can help. For the shoot; when (shoot key) pressed down, if variable (ammo) is more then 0 change variable shoot=1 else change variable shoot=0 when (shoot key) left up change variable shoot =0 every few seconds (time depending on the fire rate of the weapon) if variable shoot = 1 (do your shoot commands, however you want to script those) set/change variable (ammo) -1 then whenever you pick up an ammo box: set/change variable (ammo) + (amount of bullets) |
||||
|
That the code for a machine gun or any weapon that you want to continue firing as you hold down the mouse btw. For health, the script really matters on what kind of enemies you have and how you handled variables for them, but here's a system that would harm you continuously over time while in the proximity of another scene node. ; before first drawing; set variable health to 50 every few seconds if variable health is less then 1 (death behaviors, you decide) on proximity to scene node entering proximity (bad guy, bullet, any scene node you want to do damage to you when your close to it) change variable damage to 1 on leaving proximity to scene node (bad guy) change variable (damage) to 0 every few seconds (anywhere from 1/2 a second to every 2 seconds, you decide. if variable damage=1 change variable (health) -1 |
||||
|
Also, if your looking for a health bar type of thing, line up 2d overlay blocks to make a health bar. then in a behavior scene node (don't put it in the blocks because they will be hidden) every few seconds; if variable (health) is less then 40 hide (block furthest right) else; make visible (block furthest right) do this with all the blocks, with the "less then 40" going down by tens (or whatever turns out even with the amount of health and how many blocks you have). This will make blocks hide themselves in order to display your approximate health. It's not perfect, but it works. Hope some of this helps. |
||||
|
Great stuff, this will definitely help me out for future projects, thanks for sharing |
||||
|
can you make a video on the health bar?? im not sure how to do it |
|