Hello, i have a create crosshair widget blueprint set up if my character is not unarmed.
im trying to set it up so if i drop a weapon the widget removes from parent but for some reason that line of the code doesnt seem to work.
any advise or suggestions are greatly appreciated.
Event Tick fires every frame. You’re creating 60 crosshair widgets a second. Create it once, on Begin Play perhaps. And then hide when the player becomes unarmed. Do not use Tick for this.
when the weapon is equipped, call an event dispatch called something like “WeaponEquipChange”. Give it a bool as the signature and make it true.
when weapon is dropped, call the same event dispatch and make the bool false. Now this one event informs anybody else that wants to know when a weapon is equipped or dropped.
in the blueprint where you handle UI stuff, bind to this event. When the bool is true, create the widget. When the bool is false, destroy or hide the widget.