I’m currently trying to call an event in one sublevel (SublevelA) from another sublevel (SublevelB). I have created an event dispatcher in SublevelB and tried registering the event from SublevelA, but I am struggling to bind the event dispatcher from SublevelA.
Is there a way to access a sublevel from another sublevel?
The method you explained was the idea I had, but I was wondering if there is a way to directly talk to the sublevel instead of going through the game mode (or in my case, the game state).
Well sorry, then probably someone else can help you. I only know that Levels are supposed to be exchangeable and that it is recommended to handle Level specific functionality only.
And when I look this up now it seems nothing has changed since I needed to check this for myself few month ago.
GetAllActorsOfClass will not help too if you still need to route events through your an Mediator-Actor.
Just my personal opinion: As someone who loves to design framework architectures in different environments (not only in UE), I would not do that. If you use SubLevels then you are about flexibility, if you wire them together then you lose it. Well if you got tons of events it might be bad to route them through the GameState, but then you probably want to have a message oriented approach anyway (Just a single event with different EventArgs to make it dynamic)
You do have a good point! Currently I may only have at most 5 events I need to use to communicate between sublevels. I wasnt sure if the method that you and I thought of was the elegant way to do things. But if there arent any other ways to achieve the behavior I want, I will use the method you suggested!
Yep it is always good to have a solution ready and still check for alternatives
Just think what you would do to exchange your sublevel or swap your levels at all. If you need to copy&paste nodes, macros and functions over to the new levels instead of reusing them within your GameState or GameMode,…, then most of them are just in the wrong place And I think you don’t want to bother with breaking references to the SubLevel when doing this
There are other people looking for alternatives as well and trying hard to cast StreamingLevel and so, they would be happy if you close this question with your final solution then