Shield damage in certain areas?

I want to create zones where the player when entered gets damaged schield.

The player enters a certain region
Shields starting to fade 100 - 0

And what if i have two of those zones crossing each other, how do i manage this?
I tried it with the player damage actor but this was a complete failure.

I’m pretty sure a damage actor just applies the damage event to things that enter it. You need to implement it. Try using the on damage event and having it change a dynamic material.

Yeah you want to use a volume and setup your own variables for it, don’t try and use the damage 1. Just do a cast to the player character when in the volume and minus his shield value. If you are in overlapping zones then they should both be casting across to the player and make it drain twice as fast

thx… but: I cant correctly add the damage to the player…

Firstly: How to make it draining over time if it is only activated once?? BeginOnOverlap

Then: If the leaves the place in to another box how should it not stop?! EndOverlap

I really need some halp here :expressionless:

EDIT: I scrolled through the entire Wiki for Damage and didnt found any way to deal with pain causing volumes. :c
How to people create Fire damage?? Or damage caused by simple things like breathing under water???

You can create an array variable and then, on BeginOnOverlap, add the overlapped actor to that array. Then, every tick, damage all actors within said array. On EndOverlap, you can remove the actor from the array.

Replace the damage function with anything you need to.

Woaaa this is crazy :o my first time with arrays!
gonna test

Yes! That totally works fine to me! So much thx to you all :slight_smile:

[crime solved]

Congratulations :slight_smile:

And now how about a solution that does not involve arrays and for each loops :slight_smile:

First add an integer variable to the player BP and call it “DamageDriver”, or something simmilar. The default value shall be 0.
Also define a “BaseDamage” value. This this something like the fundamental unit of damage in your system.
Then add an “OnTick” event to the player BP and calculate there something like: Shield = Shield - DamageDriver * BaseDamage.

Now, create your damage volumes and let them overlap or not. Place them however you want.
In any BeginOverlap event of a volume, the “DamageDriver” variable is incremented by one. And in every EndOverlap event you decreae it by one.

This way you have always the numer of volumes that contribute to damage.
If you are not inside any damage volumes, you dont get any damage applied as:
Shield = Shield - DamageDriver * BaseDamage.
Shield = Shield - 0 * BaseDamage.
Shield = Shield - 0.
Shield = Shield

So its kind of a reference counting on entered volumes.
As all events have only a simple calculation/operation (in/de-creasing a value and make simple arithmetic), it should be way faster than the loop solution.

Only limitation: All damage volumes will apply to same rate of damage. If you want areas with different rates of damage, then you need to need a slightly different approach, but that is also solvable without any loop or array :slight_smile:

Running a loop on tick is not a good programming practice. Sure it works fine in this instance since it is a very small loop, but if you are having hundreds of objects doing this then you get major headaches.

My point exactly :slight_smile: