Is there a way to send an event from a projectile hitting some actor to the level?

From what I understand sending events requires referencing at least one BP - that of a sender, or that of a receiver. When calling an event dispatcher one has to reference the receiver BP, when binding an event (on the receiver side) one has to reference the sender. Trick is, there is no such thing as “referencable” level BP, and as projectiles are dynamically spawned there is no way to reference them in the level BP while binding an event, so I don’t see how to code that.

I want to test a condition that depends on the states of several actors that were hit (their states change on hit). I can easily check their states from the level BP. No problem doing that on tick, but it is unnecesarilly costly, so testing only OnHit would be much better. That requires knowing when the hit occurred.

In your Level Blueprint, you can just get all the desired actors and call Bind Event to On Actor Hit on them. You can then grab the Other Actor parameter for the event and check if its your projectile. If yes, you can proceed with the required logic.

Also, if you’re going to have the same mechanic in more than one level, I’d suggest implementing it in a new Actor blueprint that you can drop in the level. The problem with Level Blueprint (apart from not being able to contact it directly) is that it isn’t reusable. You’ll have to copy over the logic to every new level. With an actor blueprint, it’s just a matter of placing it in the level and providing references to the objects that you’re listening to.

Perhaps I am dense but I don’t see how to get the desired actor, that’s the problem. Is there a way of referencing in BP an actor that is not present of the level? I know how to create a a reference to a selected level object, but I don’t have projectiles on the level while working on the BP, so I can’t just select them, then in BP right click/create a reference.

It will be just on this particular level. Still, no idea how to reference the projectile in another actor, so I wouldn’t be able to implement the idea for exactly the same reason I can’t do it in level BP.

But you do spawn them, right? Bind an event as soon as the projectile is spawned.

I don’t spawn them in the level BP, so I don’t have the reference to the projectile in level BP, which in turn means I can’t bind an event, that’s the problem all the time.

I am sure I am missing something basic.

Player shots and FirstPersonCharacter BP spawns the projectile. The projectlie exists, but to bind an event to the projectile in the level BP I need to reference the projectile. I don’t have the reference to the projectile in the level BP as it was spawned in the FirstPersonCharacter. How do I reference this projectlie in the level BP?

I know how to reference actors that are present in the level while editing the level and BP, I can access them through the UE UI, I have no problem with actors spawned by the level BP with SpawnActor, as the reference is returned in the level BP and ready to use. Projectlie is spawned in some other place and I don’t have access to the reference in the level BP.

Do I need to create an additional event/dispatcher to send projectile references from the FirstPersonCharacter to the level BP? That I probably could do with GetPlayerCharacter.

It does not matter where you spawn them. Use the Return Value of the Spawn Actor node:

Why do you need the Level Blueprint in the first place? You can make an entire game without ever touching the LB.

When the bullet hits anything, you get the reference. You can and should consider doing it all in the player blueprint, where it’s most relevant.

The level blueprint is good for placing actor and perhaps scripting stuff that is unique to that very level.

I was referring to the actors that are being hit by the projectile. If there are only a handful of them that you’re interested in, then one easy approach is listen to them (instead of listening to projectiles) being hit by something.

So in the example screenshot I shared, Power Core is an actor that can be hit by enemy projectiles. So I’m telling the Level Blueprint to listen to every instance of the Power Core being hit by something. Every time it gets hit, I can check if it’s a projectile, and if yes proceed with the required logic.

But if there are lot of those actors that you’re interested in, then @Everynone has already provided the answer. And since your First Person Character is the only one spawning the projectiles, it’s just a matter of adding a dispatcher to listen to the projectiles as soon as they are spawned.

1 Like