How best to check overlap for more than one actor?

So I have a bullet, and I want it to destroy itself if it hits any of these 5 specific actors. I know how to cast to 1 individually, but not how to fire the overlap if it hits any 1 of 5.

if the other actors are of a similar type you could have them inherit from one parent actor. or you could use tags to identify them, use the actor has tag node in this case.

Can I retroactively have them inherit from a parent as child actors? And if I use tags, how do I cast to “any actor with tag” to overlap?

Can I retroactively have them inherit from a parent as child actors?

yes you can by going into the class settings and changing its parent. though it can mess some things up if theres other inheritance dependencies that you dont take into account.

how do I cast to “any actor with tag” to overlap?

you dont. as stated above you would use the actor has tag node. the “actor has tag” node basically just checks if the other has the tag your looking for. a cast just compares to see if the class you feed it is like another. in your case you dont really care what the other class is specifically as long as it has the tag. put another way lets say the actors with tags are the ones that can be damaged, you dont care what your damaging you just care that it gets damaged. ill post a picture below that shows what i mean.

in the example i set it up so on overlap the bullet checks if the actor it overlapped had the tag aka does the bullet care about the other actor. then we use a branch to control the scripts flow, if the actor has the tag cool we damage it, if not we dont care and do nothing.

Alternatively you could use the very efficient “interface” system. So in each of your actors on overlap just have them fire this logic off. And in the “bullet BP” implement an interface that destroys the bullet. This way you can have many actors destroy the bullet and they don’t necessarily have to inherit from the same parent. This will give you the most flexibility moving forward as they would just call the interface on overlap and not have to worry about what actor overlapped the bullet.

There is one more step i need to do, The actor that it just overlapped, how do I get the location of that actor specifically so I can teleport to it?

you just drag off the other actor pin and search for get actor location which will provide you with that actors world space location.

as for the teleport itself that depends on how you want to implement since theres a ton of ways to accomplish it. the most basic way to teleport would be: get player character → set location (from within the bulllet). you could also control the teleport in your player. and or have a variable reference in the bullet to the one that fired it which may be good for multiplayer.

Ok. So I am making this sidescroller action game, and in it there are five different enemies. The player has an ability where he will be able to aim in a 360 degree arc a beam (made up of constantly shooting projectiles that destroy themselves after passing limited range). What the projectile does, is that if it collides with one of the 5 actors, it spawns a teleport anchor, and the player can then use the teleport ability to move there. It is setup so that the anchor destroys itself if the player is missing.

This BP is for the projectile, which needs to only respond if it hits the center of the enemy character, because some of them have collision boxes used for sight that are fairly large. The issue now is that with the above code, with projectile immediatly despawns because it is registering a hit with the enemies vision range, not the mesh of the enemy itself.

What if I need a certain component on the actor (but they are named the same on each actor)

getting a specific component isnt what you were asking for, you actually hadnt mentioned that at all. really it depends on the situation, im sure you could cobble together a system that uses a interface to exchange references and check if a particular component was hit but it wouldnt be very modular or well organized. or if you had inheritance on your side you could get the parents components but anything specific to the child would be difficult.

try explaining your situation and the context so we can understand what your trying to achieve. that way we can provide a more specific recommendation and have a more similar thought process to you.

got it! thats a much clearer image of your goal. one more question are all the 5 actors characters? if they are then its easy you just cast to the character class, then again if it were that easy you probably would have done that by now. how about creating a custom collision channel? or you could use the on component begin overlap node which will allow you to get specific components of the target actor. or use both.

i actually dont use tags much so i didnt realize theres a “component has tag” node, i believe you can use this node in conjunction with the on component overlap to get the result you want. you would just need to give the main body of the actor the right tag. i havent tested this and dont have time at the moment so its just theory but i dont see why it wouldnt work.