Hello everyone. I am trying to design a UI architecture for my project. I have two modules related to this, LimenGame and LimenUI and I have a LimenWidgetController class responsible of communication between these two modules. I planned a widget controller to keep track of a few data like FGameplayAttribute’s and notify the widget class whenever any of this data updates. For example a HUDController will keep track of Health, Stamina, Mana etc and send notifies to actual HealthBar, StaminaBar and ManaBar widgets whenever these attributes’ values change. I create and initialize just the WidgetController objects in my PlayerController class and WidgetController object itself is responsible of creating the Widget objects. I use OnRep_PlayerState to call CreateAndInitializeWidgetControllers function in my PlayerController class, I believe this is a suitable place for initializing WidgetController’s since they require PlayerState. When created and initialized with necessary data by PlayerController, WidgetController class just subscribes to GameplayAttributeValueChangeDelegate’s from ASC which I get from PlayerState and adds the widgets to the viewport. After this, I don’t do anything in C++. I am sure WidgetControllerClasses are set in PlayerController’s blueprint, I am sure WidgetsToCreate are set in WidgetController’s blueprint, I am sure RelevantAttributesToTrack map are set in WidgetController’s blueprint., and I am also sure that RelevantAttributeTags are set in the Widget’s blueprint. In widgets itself, I just check one more if the FUpdateWidgetData passed in in the latest Update call from C++ has the required tag for this spesific widget (for example HUDController will bind to all resources like Health and Mana but one of the controlled widgets HealthBar will only be interested in Health).
If yes, I proceed with the logic of that widget, for example interping the progress bar percentage for the previous example. I shared full code of every class I mentioned and every blueprint of them in this message. What’s happening right now is the editor just crashes whenever any damage is applied to any player. Note that before the UI implementation applying damage was working fine. I really have no idea what’s causing it. So far I checked FWidgetControllerParams I use to initialize WidgetController is VALID. ASC used to bind to GameplayAttributeValueChangeDelegate’s is VALID and logs successfully bound messages. Anything that needs to be set from the blueprints are set. When I use debugger, it sends me to file BitArray.h line 1926 at the moment of crash. So it may be some replication error but I definitely do not have this advanced knowledge about the engine source code. But I believe my replication setup for attribute set and every attribute inside is correct. PlayerState is the owner of AttributeSet, it creates it with CreateDefaultSubobject. AttributeSet object itself has GetLifetimeReplicatedProps function, every attribute defined with ReplicatedUsing = OnRep_AttributeName macro and has DOREPLIFETIME macro in the .cpp as well.
Here are all the files I mentioned above. I couldn’t fit them in text or screenshots, they are just GitHub Gist links so I’m assuming that I am allowed to post these. I will remove them if links are not allowed. LimenPlayerController.cpp · GitHub LimenPlayerController.h · GitHub LimenWidgetController.h · GitHub LimenWidgetController.cpp · GitHub LimenUserWidget.h · GitHub (LimenUserWidget.cpp is just empty so I didn’t bother) And this is the only blueprint code I have about UI (WBP_ProgressBar) ProgressBar posted by anonymous | blueprintUE | PasteBin For Unreal Engine