Enemy Life Not Working?

RyanTNT

  • Posts: 14
The code's not working as I thought it should. Any help?


CmdrWhitey13

  • Posts: 504
Life should be initially greater than 0 if not already specified.
Where t says kill self, drag down the 1st actor block above to the self location.

Hope it helps.

RyanTNT

  • Posts: 14
life (as a numerical attribute) is preset to 3.
and the other thing, do you mean the tag "1st actor"?

RyanTNT

  • Posts: 14
i could set to 3 aswell in the "when created" section.

RyanTNT

  • Posts: 14
tried it, but still just does the same thing.
thanks for the suggestion, though!

« Last Edit: February 10, 2018, 08:51:36 pm by RyanTNT »

Luyren

  • *
  • Posts: 2747
When debugging, put print blocks with either text or attribute values in every step of your code, until you see the part that is not executing, or if an attribute's value is wrong.

As for your problem, you didn't explain how you think it should work, versus whats is actually happening in-game. With that said, check if your actors are set to collide with each other.

« Last Edit: February 11, 2018, 08:54:57 am by Luyren »
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

ViniciusAlves

  • Posts: 45
Is the hurt event in a When Updating? Because your character might be detecting a lot of hits at once, so the "life" goes below zero. Try to substitute the "When Life = 0" for a "When Life <=0".

RyanTNT

  • Posts: 14
@Luyren) what do you mean by putting print blocks? Is it to visually show whats happening and whats not?
And whats supposed to happen in-game is that when the sword hits the enemy 3 times (life is set at 3 when created) it will simply dissapear, for now. And yes, it may be checking every frame for that, so he should dissapear almost instantly. What actually happens is when the sword hits the enemy, nothing happens. Not even holding it or pressing it down lots of times will effect that.
@ViniviusAlves) The hurt event is not in a "when updating", its in a custom block. And I'll try substituting "life=0" for "life<=0" Hope it helps.

RyanTNT

  • Posts: 14
nope, still doesn't help. Thanks, though!

Luyren

  • *
  • Posts: 2747
@Luyren) what do you mean by putting print blocks? Is it to visually show whats happening and whats not?
And whats supposed to happen in-game is that when the sword hits the enemy 3 times (life is set at 3 when created) it will simply dissapear, for now. And yes, it may be checking every frame for that, so he should dissapear almost instantly. What actually happens is when the sword hits the enemy, nothing happens. Not even holding it or pressing it down lots of times will effect that.
There is a block under Flow > Debug that reads [print (anything)]. This should display whatever you put there in the console (on the Stencyl head menu, go to View and select Log Viewer). This should help you see if your code is executing at all.

This looks like they are not colliding at all, so you should check the actor groups to make sure they are set to collide with each other (your actor and the sword).
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter