How can I access a custom event in a level BP?

I add a BP called Ennemy. I spawn some in my game. I create an event call “Begin Life” that I want to fire up in my Level BP when I spawn my Ennemy. In my Level BP I had an array of Ennemy but I can’t access to the custom event in it ? What I’m doing wrong ?

Can you post an image of your Blueprint so that we may take a look?

-W

No one have idea

You can achieve that by “Begin play” Event node.
Add “Begin Play” node in Enemy BP instead of a custom event and it’ll do the job for you since it’ll be fired at the moment your Enemy object is spawned.

EDIT: I think there’s no need for Event tick in Enemy BP

I spawn my ennemies character with a delay. So at begin play there’s no Ennmy objects that I can setup their goal.
The event tick is want i want to remove, I’m ok with that. There is no need to update each tick the goal. That’s why I need a custom event.

Sir,
you are spawning an enemy every 1 second in you level BP and setting the “goal” their too.

you said you want them to move at the moment you spawn them,

  • you spawn an enemy
  • set it’s target
  • If you put “begin play” node inside Enemy blueprint it’ll be fired when it’s spawned !
    that should work.

Now let’s say you need another custom event inside Enemy BP, you can access it from Level BP by dragging a node from “As enemy C” pin and type the name of the custom event(make sure context sensitive is checked )

Ok, thanks. I’m going to try with begin play. I asked this question because when I’m dragging node from “As Ennemy_C” I don’t have my custom event in it. I don’t know why it did not appear.

I just tried event “begin play”. This event is fired at the start up of play and as I have not any ennemy my goal is not set and my ennemy don’t move. I’m still not able to get my custom event in my level BP, why?

YES that’s true my fault I apologize, that happened since you are trying to call an event inside the level blueprint,
the solution for this is to use event dispatcher
here is what to do:

Add an event dispatcher to Enemy BP

Assign it to “Begin live” event

from level BP call that event

hope this works :slight_smile:

EDIT: I’m going to answer this with an example

simple example to show how to do so :slight_smile:

I’m just spawning a cube_shape in my level BP and printing a “Hello” using custom event

Cube_Shape_BP

Level BP

[Result][3]

Thanks a lot. I don’t know why. But after trying 1000 times, my custom event is appeared in my level BP. But when I call this event at the end of my Level BP, it don’t fire up the event. It’s due to what you say about event dispatcher ?

could you please post an image of your blueprints after modifications ?

I tried the event dispatcher but I don’t know how to use. So I use It as you show me and with a link to Begin Play event. But both are still unsuccess. I tried to put my ennemy BP graph in function instead of calling with an event. But the function is never called (I placed the function in place of custom event in level BP).
The only way I found to make it work is to parse my array at every tick after create my ennemies and then call the custom event and then set a bool to block the call after one made. It looks like the object created in current sequence is not able to receive events.

you are missing an input in “cast to AIController” node

EDIT: here’s the official documentation for Event Dispatchers in BP

Oops, but it changes nothing. I think there is a register for events and when you just create your object it can not accept event since the instructions queue is ended

Do you have a navigation mesh in your viewport ?

Is the goal that are you trying to reach is blocked/couldn’t be reached ?

Yes, I do have a navigation mesh. The only I found to make it work is this.
But I don’t satisfy me, cause if I have 100 or 1000 character I need to parse the entire array. It’s awfull. I will try something else.

I’ve just walked-through all of this again,

why do you cast to the same type of the output of spawn node ?

You can add at the end of an array by using add node instead of insert.

I don’t know if it will solve the problem but let’s try this :slight_smile:

in your Enemy BP
create an event dispatcher,assign a event to it as you did before.

in level BP try to spawn one single enemy,set it’s goal,add to the array and call “Begin life” custom event.

If something went wrong try to watch the values that you are setting.

waiting for your response

In fact after Spawn node, the returned object is a pawn not an Ennemy. So I have to cast it. I replace my insert by add node. It simplifies my graph, thanks. I make changes that you tell me in my Ennemy BP and level BP, but nothing happen. My custom event is never fired.
Does “Bind Event to Dispatcher” need an event to lauch the bind ?

oops, yea you are right, it returns a pawn object in contrast to |spawn actor from class| node, anyway

Event Dispatcher is like a container for events, so by binding one or more events to an Event Dispatcher you can cause all of those events to fire once the Event Dispatcher is called.

Calling the event dispatcher will fire all events inside it.
Calling a specific event inside it will call only that event.

This video demonstrates the idea.