Character magic spell collision

I am working on creating a lightning spell blueprint using a particle with collision. There is a delay node on it so it only lasts 2 seconds when cast (about the time it takes for the particle to complete). It spawns at the player location and is intended to do damage to any surrounding enemies (on event begin overlap).

What i have found is that any enemies that are within the bounds of the spawned collision box are unaffected. However, if an enemy is approaching when i cast, and they overlap the outer boundaries of the collision box, they take damage. Is there a way to make any enemies already within the boundary of the collision box take damge when it spawns?

Hi,

There is a helper function you can use called Get Overlapping Actors, which returns an array of actors already overlapped with the component in question, with an option to filter for a specific class if needed. There is also a helper function called Get Overlapping Components if that is something you need as well, but I think you just need the first.

However, I found that for this to work via Event Begin Play, I needed to add a short delay (0.2 seconds) or use Delay Until Next Tick node, in order for it to return the actors overlapped. I hope this information helps.

image

2 Likes

Very good and thank you. I used this in tandem with print string. What is interesting is that i get a successful hit on actors that do not take any damage, while actors that do take damage or die show that they have not been hit.

Here is how i implemented your proposal:

This is the BP for my magic spell parent:

It is simple enough. Still not sure why it only hits one enemy at a time. Thanks again!

Sorry! Just wanted to add. Your suggestion got me thinking about that do once node. When i took it out, suddenly it hits all enemies. The problem is now that its obviously hitting all enemies about a billion times a second, so even a damage of .000000000001 kills all enemies instantly. Is there something intermediary to do once and no do once?

I would recommend storing each other actor that passes any checks (not pawn class, or of specific enemy class) into an array after applying damage. Then, when a new overlap comes in, you can check if this actor already exists in that array, and not apply damage to it if it does.

1 Like

Ill get to work on it and let you know!

That works!! Thanks for the help! You rock!

1 Like