Ignore Self on Overlap

I have a spell where I spawn an actor in my hand that can then apply damage to the enemies I hit. There is a problem, sometimes this actor hits myself and gets destroyed. How do I avoid overlap with myself? The way my game is setup I have to do this in the actor event graph, not my character’s

I tried with other actor different then my character but it didn’t work

Hey @TheSceriffo! This would be a great time to use a Tag, which can be applied to any actor, then use this node here:

image

You’ll go to the enemy actor and throw something like “Enemy” in the tag line (Select the root component, go to details, search “Tag” and you should see a +).
Just make sure they’re the EXACT same. A space at the end/beginning will mess it up.

Then you can use that node in place of your “Actor ==”, and set the branch to use TRUE. So it’ll be "Does this actor have the ‘Enemy’ Tag? If yes, apply damage etc, if no, do nothing.

Every spawned actor has an owner. You can set yourself as spell actor owner. Then in Other actor node, check if Other actor == GetOwner() and you can then ignore damage.

This is how I check if my actor are hitting their own bullets.

1 Like

And how do you set the owner?

Would that work for multiplayer?

The Tag idea would work for Co-op, but not pvp or Co-op with friendly fire.

Co-op you would use the tag, Co-op with friendly fire or PvP you’d use the Get Owner.

To get the owner you just right click on your fireball actor’s Event Graph and just type getOwner.

I want a pvp system so I’ll go with the owner. However, how do I set the owner to be my character?

If the Player is what spawns the object, that specific player Blueprint is the owner of said actor. You don’t need to set anything :slight_smile:


I set it up like this but it still won’t work

The actor still gets destroyed as soon as I overlap myself

Is the spell thrown/shot?

no, it’s a sphere that appears in my hand and remains attached until it begins overlap

btw I tried it with a projectile too and it didn’t work either

Ok then…

Use the begin overlap to do a sphere trace. Use the spells location as the start and end location, and the spells collision radius for the trace radius.

Ignore self and collision capsule.

Use the trace hit result for applying damage.

I’m working in the actor (spell’s sphere) blueprint, ignoring self won’t ignore my character

Also, this whole thing is to destroy the actor at the right time, damage hasn’t been a problem yet

When you spawn the Actor pass a reference to it, or “Get Owner”.

Ah wait, I think I know what’s going on.

Owner is not being set at the initial spawn, and your collision is handled at that point (before owner was set). Which means, you get collision event handled as soon as object is spawned, and this is what is causing the issue.

First solution:
You might try GetInstigator, instead of GetOwner. Does that work for you? Make sure you pass owning Pawn as instigator. You can see the node pin in the image bellow.
image

Second solution:
This is the one I’m using in my game (because I had the same issue as you do now). So, do not to use actor overlap, but use specific collision overlap. This is how we will resolve collision happening before BeginPlay. So make sure your projectile has some sort of sphere collision. Remove the overlap logic you had now, and then in BeginPlay of your spell actor, use this image as example, this is from my game.
This will make sure you have collision handling afterBeginPlay, And, therefore, you will have owner ready so that you can do necesarry checks

Try adding the node “Ignore Actor When Moving”, plugged into “Self” into your construction script.