Is there a way to have a direct access to an Actor in the Persistent level from one of his sub level?
By direct reference I mean selecting the asset in the viewport, right clicking in the blueprint and having the options to "Add reference to ‘MyActor’ "
Right now I have
MapMain (Persistent Level)
Map1
Map2
And I want the level blueprint of Map1 to be able to have a direct access to one of the actor that is in MapMain.
I have MapMain hold all the actors that would be persistent and Map1 and Map2 would hold static assets that would need to be streamed when needed. Map1 and Map2 also holds their respective triggers for various interactions.
I could do a GetAllActorFromClass but it would be nice to be able to have access to the objects from the persistent level
Hi, did you ever find a solution for this? I would also like to reference actors directly between multiple streaming levels, but it doesn’t seem technically possible as levels are self-contained. The only thing that crosses levels is the GameInstance and using state variables on that for all of my inter-level interactions doesn’t seem feasible.
The way I approach this problem in my own projects is to create my own custom AGameState subclass, and have a UPROPERTY field on it something like, AMyActor* PrimaryPlayerActor, and then in the BeginPlay() implementation on the AMyActor subclass, I have it get the GameState and set itself as the PrimaryPlayerActor property. Then the various level Blueprints (or whatever) can get the PrimaryPlayerActor from the GameState whenever they need to reference it.
Thanks for the suggestion. It seems like that solution works if you need only a few “global” actors. I will have many++ interactions across levels, like a switch in level 1 opening a door in level 2. Ideally, I would like for a level designer to be able to reference actors between levels right in the editor (i.e. set the target door for a switch in the actor properties pane). But I know that’s a pipe dream
I’m still trying to find a way to accomplish this as well. If a solution has been found for how to reference actors in the persistent level from blueprints I would love to hear about it!
For me is to see at least one actor across all levels (it is a very large actor), and have a LookAt on the player always looking at the actor across levels.
From what I understand this isn’t totally possible, though I’m sure there are some workarounds but unfortunately you can’t get references to the level blueprints. The only options I’ve found is rather than have “persistent” objects have the level (or another blueprint) spawn it into the world on creation and store those references somewhere like GameState or GameInstance. Surely not ideal but is what we have to work with. Wish I understood the reasoning for not being able to reference level BPs
I would suggest that instead of trying to reference an object directly in another streamed level, which is an inherently brittle thing to do, consider using an event dispatcher or a [blueprint interface to implement a function that does what you want it to do.
So instead of trying to manipulate the objects directly in the streamed level, you throw an event or call a function, and then the level blueprint that contains the objects does what you need it to do with them. In the long run, this is going to be safer and less-prone to breakage than trying to reference objects across levels.