I'm having a bug where my UI doesn't properly close. My branches don't seem to be working.

So I’m working on my game and I have this frustrating bug with my code, and I can’t seem to figure it out. I was curious about coming here and seeing if anyone can help. Here’s an explanation of the bug and pics of my code, I’ve also attached a video of me doing the bug.

Open the katana or weapon wheel. Then while holding it open, press the weapon wheel or katana wheel (opposite of what you have open currently), a weapon or katana will equip and then the previous wheel is stuck open.

Here is my code:

If anyone has any ideas lmk. I’ve tried using Do Once gates and Branches and it doesn’t seem to work.

Hi there,

I can’t see what exactly going wrong in the logic however better print out WheelOpened/Closed strings to distinguish what is going off. I suspect one of the bools causing problem to already active wheel not trigger closing or input being not consumed because of another function.

On the other hand I would like to suggest couple of simple but efficient design/programming patterns to ease your pain.

  • When you press a button you create a wheel umg. Promote this to a variable like CurrentMeleeWidget. On your logic rather than using bool IsSomethingActive check your variable IsValid(CurrentMeleeWidget)-> If(Not) → CreateNewWidget->SetVariable(CurrentMeleeWidget)
  • Create a function as CanInteract() and try writing your gameplay logic inside whatever you need, IsWeaponEquipped, IsWidgetActive etc. rather than distributing bools inside and outside of function. EX:
 // if there is no widget then on press create one for me.
Input(Pressed) -> CanInteract( If (CurrentMeleeWidget -> false ) & (CanDo- > true) & If(CurrentWeapon -> true) )-> CreateWidget()

 // if there is a widget then on release destroy else do nothing.
Input(Released) -> CanInteract( If (CurrentMeleeWidget -> true) & (CanDo- > true) & If(CurrentWeapon -> true) )-> RemoveFromParent(CurrentWidget)

// This function better be unified for both so if one menu created we know that if cannot create additionally or we can try destroy first (other) then open.

In other words a bit refactoring/cleanup operation on your side I beleive simply should solve problem.

i can send a video shortly including print strings on my bools to show what is happening.

My weapon wheel and katana wheel active boolean checks were only to try to stop the bug, but its not even working, so I appreciate your efficiency suggestion, but unless we can figure out the bug, optimizing the efficiency of the code isn’t the largest concern. Thank you for the idea though, it’s a smart one

Hey I solved it actually. I was setting up the print strings for the post and I realized that the weapon wheel and katana wheel close was being called during the swap bug. I put a branch on the released call to check if the opposite wheel is open. This seemed to fix the bug!