Damaging health bar/custom health

Grrr

  • Posts: 25
How should I damage health bar or make custom health for enemy or hero?

decafpanda

  • Posts: 205
You need to create 2 number attributes.  Within your health behavior,   "Health" and "max health".  "Health" can be hidden but do not hide "max health".  Refresh the screen using Cntrl R then go back to the actor's tab.  Go to the health behavior you created. There should be a section for "max health".  Fill that with the desired number of health you want your enemy to start with.

Now the code attached to this behavior. 

When created- set "health" to "max health"

When (insert actor that will collide with the enemy and damage it) collides with self,  set " health" to "health" minus  (insert a number of damage.  this probably should be an attribute that is tied to your damage)  if health is less than or equal to 0, kill self

This will work perfectly if the actor that is causing the damage kills it's self on collision.  If not you will have to wrap this code in a boolean statement so stencyl does not register multiple collisions on hit.

Oh and if you are using this for your hero, you will want to use game attributes  (purple ones) instead of blue ones.  This way you will keep your same health when you change scenes.  The enemie's health attributes should be blue though

Grrr

  • Posts: 25
You need to create 2 number attributes.  Within your health behavior,   "Health" and "max health".  "Health" can be hidden but do not hide "max health".  Refresh the screen using Cntrl R then go back to the actor's tab.  Go to the health behavior you created. There should be a section for "max health".  Fill that with the desired number of health you want your enemy to start with.

Now the code attached to this behavior. 
When created- set "health" to "max health"

When (insert actor that will collide with the enemy and damage it) collides with self,  set " health" to "health" minus  (insert a number of damage.  this probably should be an attribute that is tied to your damage)  if health is less than or equal to 0, kill self

This will work perfectly if the actor that is causing the damage kills it's self on collision.  If not you will have to wrap this code in a boolean statement so stencyl does not register multiple collisions on hit.

Oh and if you are using this for your hero, you will want to use game attributes  (purple ones) instead of blue ones.  This way you will keep your same health when you change scenes.  The enemie's health attributes should be blue though

Is there any video tutorial or screenshot to see it better?

KramerGames

  • Posts: 405
I think there was a health bar in this series:

https://www.youtube.com/watch?v=yYYhkLXfMAI&t=4s
Parasites United  (Idle Parasite Game)

Grrr

  • Posts: 25
I think there was a health bar in this series:

https://www.youtube.com/watch?v=yYYhkLXfMAI&t=4s
That video has nothing about health.

squeeb

  • Posts: 1492
@liberado has a visual one that changes based on health attributes somewhere in the forums to download and use..... longer.. more health.. and shorter.. less health.. decafpanda said exactly how to make it... read the help docs in stencyl media on purple  attributes

Exportforce

  • *
  • Posts: 90
You can use the standard "Health Manager" behavior but since one block in that pre-defined behavior is deprecated you need to use your own check for "if health <= 0 -> kill self" but else it works fine incl. a healthbar