BP interface question

Well, Generally, I’m trying to replace all BP casting with BP interface, some of the stuff I’ve replaced already.
Now I’m trying to do the same with my projectiles that cause damage. I replaced part in player BP like that. Projectile gets HP and then changes it - works well.


But when I’m trying to do the same with enemy BP - it doesn’t work at all.

  1. Do I need to make unique BP interface functions for the enemy BP?
  2. How does it work with multiple enemies? I suppose that all of them will send their HP to each projectile, am I right? How it can be handled?

Thanks for any advice

Actors have this built in already:

And damage type classes, too. Essentially, any actor can apply damage and any actor can receive it. No need for extra BPIs.

I made a custom damage system
Is there a way to use the BP interface for this purpose or do I have to use this built-in system?

You can use your own. The BPI is implemented in the actors receiving damage. When the projectiles hits them, it sends a message to that actor.

Projectile gets HP and then changes it - works well.

I don’t understand this, can you explain? And special mechanics behind this?

But the question if I want to do such things that aren’t connected with the damage system, how can I do it with multiple targets, how to identify them to send/receive data properly

Yes, of course
Here is part of my BP projectile
The top line works for enemy BP
The bottom line works for the player BP

You get actor references when projectiles hit actors:

  • the BPI:

  • the enemy implementing the interface:

  • projectile hitting stuff:

image


I would not pull out the Health out of the enemy, modify and set it. The enemy can handle its own health.

In my case it’s AOE damage, in this case I don’t have one target
I tried to replace cast to the BPI and it doesn’t work for enemies
It works well for single player BP

You can use the built-in system:

Or your custom system:

the falloff math needs to be better in my example :crazy_face:

Here the projectiles have an overlapping collision sphere - anything trapped inside when it hits (whatever it hits) is sent a message, here filtered to one class only.

Thanks, I see that you did it in opposite way - you are sending damage from projectile and than in the pawn you are decreasing health.
Will try your approach, hope it will work

It works only for one enemy


here is the code in the projectile

Oh, I probably found the reason, by no reason, get all of actors of class gives only BP_TargetPawn2

Why would you even use Get All here? is the goal to really hit ALL actors or the ones affected by the area damage only? it may be intended, I just hate the node for my own private reasons :wink:

How many actors of BP_TargetPawn2 class are in the scene? It returns what’s in the filter.


If you’re trying to hit stuff in range, use a sphere overlap, much more efficient than iterating and then discarding other actors based on range.

1 Like

I don’t know alternative way. Yes, I’m trying to hit anyone in AOE, so I decided to get all actors and then check the distance from the position where projectile was blown.
For now I have 2-4 enemies for testing purposes.

The strange thing, If I call the same inside player BP it gives me all BP_TargetPawn, but in the case of BP_Projectile it gives only one of them

Thanks, will try

Also, in case you ever decide to revisit the native system, it has a falloff version with damage prevention channels:

So you can have obstacles absorb damage automagically without excessive tracing.

1 Like

It sounds interesting, I’m going to rework AOE, earlier missed that it doesn’t work with multiple targets and still don’t know why get all actors of class doesn’t work properly for projectiles, I checked, for each loop node never completed

Finally made this.
Overlapping works well, also found the reason why I didn’t get full list of actors by using GetAllActorsofClass - it’s because Loop Body was connected with function return node.
So, now code is clean and compact
BP_projectile AOE function


BP_projectile event graph

Event for player and enemy pawns

2 Likes