Adding Widget to Viewport with a Condition

Hello. I am trying to change the game’s HUD when player’s weapon is changed but condition doesn’t work.

does anyone know?

You should store the created widget in a variable and use that to remove it from viewport. Now you create a new widget instance which you remove immediately, that doesn’t work.

that sounds promising. do you know exactly how to do it?

Create a new variable in the blueprint (like MyWidget), change it’s type to Widget (or the specific kind of widget you are spawning), then after you use the create widget node, set your MyWidget to the returned value then add it to the screen.

when I make a variable on Widget type or any other widget type, they don’t contain any user widget bluprints. so i can’t select anything.

I’m not sure what you want.
What are you trying to select?

When you switch weapons you spawn the Widget for that weapon and set that new widget to a variable in your character so that it can be removed later when you change weapons and spawn a new one in it’s place.

I mean a variable. When you create a new variable you can type in the type of variable you want.

do you mean widget variable or boolean? because i can’t make any widget variable.

It didn’t work

I solved my problem in a single widget by using visible and collapsed variables. thank you for your help.

Well you are doing what I told you to, You are storing the widget in a variable whenever you change weapons and you delete the old widget.
But in your case you are using 3 different variables.
I would have just 1 variable “ActiveWidget” and set it’s value after those branches.
But if it works, it works.