Good day!
Game works correctly whilst in editor (in standalone multi-process mode). Although, when i package and run development/shipping build, it seems, that either multicast delegate doesn’t bind objects, as it expected, or doesn’t call all the subscribers.
Several actors on the level has actor components - event listeners and event resolvers. Listeners bind to the global multicast delegate. Actors with broadcast interface send events to the global event controller, who owns the delegate and broadcasts messages to all the subscribed listeners.
Looks like actors, who has more than one listen handler (to work with different type of events) and sends and receive messages, don’t work in packaged game.
Not sure, if it helps, but i’m adding editor and package logs.
Thanks in advance for response!
Can you make small replicatable case thats similar to your Setup? Hard to tell otherwise.
I’ll try to do one in a few days.
Hi!
So sorry that it took me so long to make this solution. I’m attaching an example, looks like it reproduces the problem.
Does not work at all inside the Game Editor (testing on 4.18)
So I made a few adjustments. I noticed you Event Controller is null when you do the Bindings etc. so I moved the EventController Creation from your GameModes Begin Play to the GameModes Constructor to make sure it exists before anyone Calls BeginPlay. Works in PIE and Packaged without issues.
Btw instead of static cast you can use UE4´s Cast function its safer for runtime since static cast can return you a valid pointer.
UDEventListenHandler* ptrHandler = Cast<UDEventListenHandler>(Handler);
Could be but I think its very unlikely. Also your Build did just Sub to a single Handler but there should be 4 Subs. There seems to be something wrong with the Order that BeginPlay is called. I know there was a Bug related to that in the past and not sure if it was fixed. Just try to put it in the Constructor and See what happens =)
Hey! Thx for your reply!
There’s no initial problem with the controller being null in the original project. The only problem is that delegates aren’t called when they should’ve been.
So, if you say it works on 4.18, maybe that’s just 4.15 version problem.
Do you mean putting bindings into the constructor?
No just like I said. Move what you got at begin play (Controller creation) into the Constructor. Did work for me and I got no issues at all afterwards.
In the original project controller always was created in the constructor, that’s not the problem. But, i’ve reread the logs and i think, i’ve understood, what may cause it.
It is BeginPlay order - looks like controller may not get a variable it needs to check before bind anyone (didn’t use it in empty project cause consider that irrelevant). I’ll rewrite this part and try to package to see if it helps.
It was a BeginPlay problem. For some reason, it’s called on some actors before it is on Game Mode. Not sure, if that’s expected behaviour, but at least now i’m aware of it.
Thank you so much for help!