Damage over time hazard

I’m trying to create a radioactive feild which damages enemies while they are inside of it

for the most part, I have it working, but theres a problem. while an enemy will start taking damage while inside the field, any other enemies that enter the field after the initial enemy will not take damage, i;m guessing this is because of the “trigger once” condition i have when the game detects an enemy in the radioactive field, but i need the “trigger once” because otherwise the timer will reset every frame and not deal damage as intended

If Your Using Variables And Find It Hard, Then You Should Just Use The Health Behaviour Its Alot Easier.

This is an example of the health behaviour, you also have to set the amount of hp they have in the players Behaviour.


While I appreciate the suggestion, I’m not finding using variables particularly difficult, just wanting some ideas on how to solve this problem as i have tried everything i can think of so far. but it’s good to know this exists!

1 Like

Walk into the tree

I need 2 wait actions because i change opacity first to 50 then to 255

You would instead put there
Change the variable hp of enemy subtract 1
Wait 0.02

Of course adjust time to your needs

THX to you i just realized i got it wrong (on screenshot/my events)
It should be
1st action to do something
Then Wait action

Because if my wait would 1 sec
Then when player is in collision with tree then it would first wait 1 sec and then change opacity
Instead of changing opacity 1st then waiting
But with 0.02 it is so fast you can’t notice it
Only if wait action would be longer it would be noticeable

So be aware of that

1 Like

took me a bit to figure out what you were meaning, but with a little bit of altering your events, i got it working, I only kind of understand why this works and the other way doesn’t but this works really well, thanks!

final code for posterity

What you do not understand?
You could simply ask

1 - You check if repeater variable is 2 or something higher
2 - If it is 2 or higher you change it back to 0 so it is always at either 0 or 1 but if 2 or higher it switches back to 0 instantly
3 - You check if repeater variable is 1 (this could be checking if it is equal to 1 but i was using more values from 1 to 5 for something blinking and for your needs i just reduced it to checking if it is 1 since you did not need more but since it works why to change it)
4 - You check if variable raddamage is false so it is not active yet while repeater is still at 1 (every single boolean you make from default is set to false same as each number variable from default is set to 0)
5 - Going from top to bottom

  • You change variable raddagme to true so enemy is able to get damage (this is because there is chance for it repeater to get stuck on 1 after you you leave collision with object which should damage you)
  • Chang hp var is just applying damage
  • Wait action is so you have like some time gap between DoT
  • Here you add 1 to repeater so if it is at 0 it goes to 1 and if it is at 2 it goes back to 0 so it can again go to 1 (kinda like making a loop where in point 3 you are checking if repeater is at 1 and only when it is at 1)
  • Here you set raddamge back to false so condition in point 4 can be meet again since it require raddamge variable to be false (so again another measure to make sure it is making full loop)

6 - If variable repeater is at 0 (which will always be if you do not collide with object that should damage you thx to that event in point 1+2)

  • You check if enemy is in collision with object that should damage enemy
  • Trigger once so it happens only once and not constantly stay on 1 which would result in not in DOT but constant damage

7 - You set repeater to 1 so whole DOT loop from point 4+5 can actually work

And that is pretty much it

For future readers, you only had to replace trigger once with (inverted) The timer “radTimer” of enemy > 0.

I agree with @Reborn

Its a pretty nice game good content with great creativity.:+1::+1::+1::heart::heart::heart::heart::orange_heart::orange_heart: