Download

How to call an event of level blueprint from NPC blueprint?

I have the following situation:

1 NPC that follows a path containing 3 parts. Target Point 1, Tower and Target Point 2.

It turns out that the first NPC that passes through the tower destroys it.

This destruction is not instantaneous. The tower has 100 hit points and while in contact with the NPC, it loses 10 life points every second.

With this, the next NPC’s will only have to go to Target Point 1 and finally to Target Point 2.

I created a boolean variable for target control (varTowerDestroyed). So if it is false, the second target becomes the tower, otherwise it becomes the target point 2.

Blueprint showing the variable (varTowerDestroyed) being set to true, right after the tower’s destruction:

**Display of the control in the target definition:

**

It turns out that each NPC has its own variables, so there’s no use in defining the value of the variable of just one of them. I would need a variable that would control all at the same time.

I thought of doing the verification based on a variable of the own tower, but as the tower will be destroyed, I imagine the variable will disappear. Impossible to verify:

At the Level Bueprint I created an event that will be called soon after the tower’s destruction. This event will set the Boolean variable to true, setting all Boolean variables of the NPC’s that are created and still generated to be true:

I would calmly call an event if the event was in the blueprint of the tower, but being on the blueprint level I was unsuccessful.

I thought about using the sleep function. I also thought about creating an actor who was sort of an actor manager (I still want to, but only when I start using HUD). I also thought about doing a check of the existence of tower actors, but this I do not know how to do.

Links from places I searched:

https://answers.unrealengine.com/questions/78622/how-can-i-call-an-event-in-my-level-blueprint-from.html

https://answers.unrealengine.com/questions/702964/how-can-i-call-a-event-from-actor-blueprint-in-lev.html

I also saw this video, but I could not:

Video #26 in the link below, I discuss how to create an event dispatcher to communicate with the level BP. Perhaps it will explain better than the video you linked…

The video is very interesting and I had seen a similar one, my problem is not so simple to solve because the object to communicate with the Level Blueprint is not placed in the world initially, it is spawned.

After Spawning an actor you can use a ‘Bind Event to’ Node to hook into events.
Don’t have time atm to follow the rest of the thread but hopefully that helps a little…