Custom Event is not fired when actor is spawned with button press

Hi, I’m new to UE and Blueprints.
I’m trying to spawn an actor when stepping on a button like this:

and that works fine. However I’m trying to make the actor walk around with the call to the Random Roam event (as in above picture) but nothing happens. Random Roam function:

If I a place an actor in the world and start, then the this actor will start walking around.
What am I missing? How come I can’t call ‘Random Roam’ from the button blueprint?
I’ve tried making a variable and setting it to the spawned actor. Also tried calling ‘Random Roam’ directly from the spawn actor node. Nothing seems to work…
Anyone have any ideas? Any help or tips would be appreciated.

well, quite probably the BeginPlay fires during the Spawn, which starts the Random Roam, the next Random Roam fires, and cancels the first one, and then for some reason fails, and your OnFail isn’t connected to anything so it just appears to stop.

1 Like

I just tried connecting On Fail to ‘Random Roam’ as well. Doesn’t seem to work.
However the Random Roam event only seems to be firing for the actor I have placed in the world.
Could this be an issue? That somehow it only fires for the actor already spawned and somehow not for newly spawned actors?
I have also tried with no placed actors and removing the Event BeginPlay.
Furthermore also tried removing the Random Roam call in the button blueprint and hoping it will be fired by Event BeginPlay.
Also doesn’t seem to work.
But thanks for another perspective.

You should try connecting a Print Text node to the output pins on the AI MoveTo so you can clearly see what’s happening.

You could very quickly have an infinite loop if you connect MoveTo OnFail back to itself like that.

1 Like

I tried some logging:
Ai_C_1 (changed the name from before) is the one I placed beforehand, and it move successfully.
However Ai, Ai2 and Ai3 are the ones spawned from the button, or more precisely it’s the references I get from the spawnActor node. Could it be I get the object references from the spawn actor and not the instance references, as Ai_C_1?
Any ideas how to get instance references instead?

nope, spawnactor returns the actual actor returned, not the class.

you’ll probably need to watch it in the blueprint debugger to see what’s happening

1 Like

Thanks a lot for the help. I will try it out when I get some time :slight_smile: