Hey so I’ve been making a small hobby project and I’ve come across an issue when packaging my game.
I understand that the build order is optimized and changed between Editor and Packaged build but I was wondering if there are any best practices that I can use to mitigate this. Basically I have a pretty annoying issue where in Editor AMyPlayerController::BeginPlay() is called before AMyPlayerCharacter::BeginPlay() but in the packaged game they run in the reverse order. This feels like a pretty major order change and I’m not sure how best to handle it.
In Editor I have a delegate executed at the end of AMyPlayerCharacter::BeginPlay to call an initialization function relating to the HUD on AMyPlayerController because it requires the character to finish its setup to run.
In the packaged game I just need to directly call that initialize function in AMyPlayerController:BeginPlay because AMyPlayerCharacter finishes initialization first so the delegate is executed before it gets bound.
I could add ‘#if WITH_EDITOR’ for the code but it feels like those 2 flows are fundamentally different and should be easily unifiable otherwise communication between Controller and Character could be wildly inconsistent between Editor and Packaged.
For slightly more context on the problem specifically, I have a set of abilities that get initialized by the Character. Every time I use an ability I fire off a delegate to update the HUD (e.g. when holding LMB you see a shot charge up). The HUD is owned and controlled by the Controller so that’s where I’m binding the Characters delegates to the HUDs functions.
The Character has to initialize the abilities first and then the AMyPlayerController::InitHUD function (executed through the aforementioned delegate) uses the list of initialized abilities by grabbing their icons from the AMyPlayerCharacters ability array and updating the UImages on the HUD.