Make a projectile do damage to enemy

dreph

  • Posts: 142
So I know there is a longer way to do this, however I was wondering if this specific code is not possible? It does not seem to work.

To explain, the ATKDamage behavior is attached to the projectile.  I just want it to insta-kill the enemy.

The EnemyHealth is attached to an enemy, and I set the HP variable to 10.  If I set it to zero, it kills the enemy right when the scene starts, as expected.  It just seems like it's just not working? I see performance fallout too when the projectile hits the enemy, but they do not die.  Could be something super simple, or it could be that this approach isn't necessarily going to work.  Thanks in advance.


dreph

  • Posts: 142
I took a different approach and made it work from the side of the enemy, so it's fine.  I'm just curious as to limitations of the engine. Thanks!

Luyren

  • *
  • Posts: 2807
When you are setting the attribute with that block, you have to type the internal name of the attribute. Usually it is the name you set for it, preceded by an underscore and without spaces. In your case, the default would be _HP. Unless you changed the internal name to be HP, in which case the problem with that setup could be somewhere else.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

dreph

  • Posts: 142
That was probably it, honestly.  However, I have often gotten away with not using the underscore before the attribute name using the same block.  Example, my working script for the enemy damage was calculated by subtracting the projectile's ATK attribute from the current HP did not require the use of the underscore.  I have seen it require it a lot but never had this issue... just weird is all.

EDIT: Actually, I'm having an issue with the same block doing something else!  I can't get the information using the appropriate underscore and everything is right, so it seems.  Take a look.  Everything shows up as zero unless I manually type in "640" for the first checkpoint, then everything fills in appropriately.

EDIT 2: It seemed to actually be a timing issue.  I delayed setting the attribute by .1 seconds and all came up ok.  I'll try to keep in mind that not all of the behaviors will spawn completely right at the beginning.

« Last Edit: November 02, 2018, 10:32:11 am by dreph »

Luyren

  • *
  • Posts: 2807
EDIT 2: It seemed to actually be a timing issue.  I delayed setting the attribute by .1 seconds and all came up ok.  I'll try to keep in mind that not all of the behaviors will spawn completely right at the beginning.
There is no way to know which behavior loads first, so you are correct in that it is a timming issue.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.