How to reference spawned actor from another blueprint?

hi guys, so i have a blueprint in which when i press E , and when I’m looking at a certain door, it will spawn a Monster in the room using spawn actor, in another blueprint , i want to check if the user then looks at the monster for a second or 2 , it will trigger a matinee , but i don’t know how to reference the spawned monster in other blueprint , i made a variable for spawned monster in door blueprint and i called it in looking trigger but it didn’t work , tried casting it, didn’t work, any idea what should i do?

here are the images :

there are several ways to do that. One is storing the grim reaper actor in a place where you can access for example your gamemode. then you can get your gamemode, cast it to your gamemode class and then get the variable with the monster reference:

image

image

other way can be adding a tag to your grim reaper actor and then cast it

other is getting all actors of reaper class and get the first found item (in the case is the only one in the scene)

anyway if you want to pick it when looking at I suggest you dig on trace functions

trace line for example will evaluate a line from a start point to an end point and if the line hits some actor it will give you a lot of information about that hit.

To make it working just be sure to turn ‘generate hit events’ ON and Block on collisions.

Good luck!
Dany

1 Like

Thank You soooooo much, this is amazing

1 Like

You want to use the level blueprint to pass the spawn actor to the TriggerLook blueprint.
Or you can use event dispatcher to pass the spawned actor from the Door to the Trigger.