Blueprint communication with spawning/despawning object

Okay, I didn’t want to have to resort to this, but I’m confused as hell by communicating between blueprints (as are many, many people - so I’ve discovered!) I have watched numerous tutorials and seen various tutorial pages, but none of these seem to break through this brick wall of incomprehension :stuck_out_tongue:

I have built some logic in the level blueprint that sets a bunch of variables that I want to use to control various things. This blueprint also spawns and de-spawns a moving object at regular time intervals.

I am trying to figure out how I can build an event graph on the moving object that will take some of these variables and use them to determine a speed and direction… This object needs to be able to run this script upon being spawned, and continue running it until it is de-spawned again. I would also like to set up a macro that runs within this moving object and listens for external events, that will then trigger changes in the object’s motion (e.g. the player presses a button, the object turns to the right).

I think I get how to use collision to get the reference required for gaining access to an actor’s variables and stuff, but I’m not using collision here… I think I need to use custom events, but I’m also confused by how these are supposed to work…

Thanks in advance!

First do not use level blueprint, because its hard to get reference to it. For such logic use game state (its very easy for everything to get game state reference (pointer).

Create logic in game state, then in any actor blueprint you create node “get game state” it gives you pointer to game state. And then cast to “BP_gameSTate” (or whatever your game state is named like). and as game state you can acess its variables or custom events.

Ps. Custom events in blueprints are just functions without return parameter. You call them from outside (or inside) just like any function.

Cool, thanks for the help… I’ll try that out!

I also thought about trying to use blueprint interfaces, because I might use these variables in some other scripts… Would that make sense?


Okay, so if I don’t use the level blueprint, how do I create a graph that I can throw into a level and have execute in the background (i.e. like the level blueprint does)?

I’m coming from having an understanding of CryEngine’s FlowGraph system, and I thought it would be possible to put an invisible entity in the level that simply contains an event graph, and will run so long as it is placed within the level.