How to make damage over time function when inside a certain area?

I’m completely new to UE5 blueprinting, and was wondering how I can make a damage over time function that only happens when inside a certain area? For reference, I want to make a toxic cloud area that makes the player lose 5 oxygen points every second they spend inside the cloud. I thought using the default damage nodes (where damage = loss of oxygen) was the best option, but I have no idea.

Can anyone help? This is what I have so far.


This is my simple damage setup, but it will obviously not loop/apply damage every x seconds. How do I make it repeat at a constant pace when player is inside the BP area (which is a box collission)?


This is inside my BP_FirstPersonCharacter to apply the oxygen reduction (default oxygen level - x damage). No idea if this is the right way to do it.

Thank you for any help <3

try with function timer.

Try it like so:

This way the toxic cloud can damage many actors. It can be improved by also testing whether the timer is already running.


I’d personally keep away from the Timer By Function Name.

2 Likes

Try calling your damage logic to event tick node.

Thank you! What kind of objects i the “TH Area of Damage” (on the far right)? Is it a variable? How do I define the area of damage?

It’s a timer handle struct variable I named to better reflect what its for:

One can right click any pin in the engine and promote it in order to automate and speed up the variable creation process; and you will end up with the correct type. And it’s connected. The fewer clicks, the better.

image

Here, it’s useful to have it so you can manipulate the timer:

Perhaps you will need to cease the damage after 30s - you can ask the timer how long it’s been running for.


How do I define the area of damage?

Many ways. You could use the box that you have. But perhaps the trigger is small and the area of effect much larger, you could:

That’s how fireballs work. :boom:

Thank you so much, however, I set up a new blueprint as the one you’ve shown me, and although it works, I can’t control how much damage/oxygen loss is applied every x seconds in the “Apply Damage” node.


In Apply Damage I have set Damage=5, but this BP doesnt communicate with my setup in BP_FirstPersonCharacter, and the amount of damage isn’t affected by what I put into this node.


This is in BP_FirstPersonChar. Just a print string setup. What do I connect to the Subtract node to have it reference the damage set in the Apply Damage node in the other BP? How do i connect these to blueprints? Should I move these nodes to the other BP?

Oh that was easy, thank you so much for your help :slight_smile:

1 Like

just a question/potential issue would setting the timer on overlap reset the timer when a second actor overlaps?

you may need a branch to test if the Timer is already active before but ive not tested that myself

1 Like

recalling it while active, won’t add it to a queue but will reset the timer.
But if you have a variable float connected to the pin Time and this value has changed, then yes, it will be reset.

Note: not all latent node has that behaviour, Load Async asset for example, recalling it will make it in some kind of queue.

As mentioned above, yes, indeed!

I’d lean towards using this:

image

Since it gets invalidated; but again, there may be as many implementations as there are people.


Regarding this:

To add to this, these can be super handy - especially the Damage Prevention Channel at the very bottom:

This way you can make obstacles that will shield an entity from damage, so the pesky exploding barrel won’t hit us through a wall. Note that no iteration is required here, we hit all actors but the damage can be ignored on the receiving end, or simply remain unimplemented.

@ingridbie - you may also want to eventually look into the Damage Type Class - once you wrap your mind around the concept, it will trivialise handling stuff like elemental damage, bludgeoning damage, resistances, mitigation and so on. Think of it as of a damage processor.

Hope this helps,
Good luck!

1 Like

i used IsValidTimer too for my dialogue system, pretty handy.

thx for the tips “Damage Type Class” :innocent:

1 Like

Ooops, I @ the wrong person, apologies! My bad.

no worries :innocent:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.