Destroy different Blueprint Actors with overlap

You can set one and the same interface event in every actor, and call the interface message inside the bullet BP for the actor the bullet overlaps with. This way you won’t have to Cast, and if any actor does not implement the interface that you call, nothing happens.


Since you might have lots of bullets flying at the same time, I’d suggest not using tick. You can set bullets to simulate physics, disable gravity, and just set an initial velocity for them.

Hello I’m learning Unreal and made a basic thing where I press F to shoot a bullet, when it overlaps an enemy the enemy is destroyed. I’m wondering how would I destroy different types of enemies? Currently since there’s only 1 type of enemy this works, but I can’t figure out how to destroy different actors depending on which my bullet overlaps.

Apart from EnemyBP, in the future I would have Enemy2BP, 3, 4, 5, Boss, etc.

there are many ways to solve your issue. first you could use inheritance so all your enemies inherit from the same class then you could cast to the parent class. by doing this the cast will succeed even for the child classes. another option would be to use tags, for this method you add a tag to every class you want to be able to destroy with a bullet then on overlap check to see if the other actor has the tag. the last option i will mention is to abandon the destroy actor in the bullet and instead have the bullet apply damage, this way only actors which you designate as being able to take damage will be affected. you could combine this with inheritance which would make it so you only have to make the script once in the enemy. the script itself would look something like (in bullet) on overlap → apply damage, (in enemy) event any damage → destroy actor. this last method is the one i would go with as it adds a greater range of functionality to your bullet, is easy to create and customize for each enemy type, and ive always found it to be good practice to have scripts that affect a actor self contained. then again this method may not be best for your add score system.

oh and on another note the way you have your set player score is not a good way to go (id be surprised if it works). you would be better to drag off the cast you have and search for get player score as you did for the set.