I awready have the code with the line trace. And it seems to work fine when aiming at an actor and then not aiming at it. The problem that i have is that i can create a widget when aiming at the actor but i don’t know how to close it properly after stopping aiming at it. Like i say my line trace works both when aiming and not aiming so i need to only make the widget to close after im not aiming.
And here is an example video how this looks like in game so i can confirm the branch if i aim or not aim at the actor acctually works (i have some effect running in a loop when aiming and it stops when not aiming at the actor to visualise that this is working). Widget gets awso created when i aim at the actor (is just simple text “Sell Traps”). The only problem It’s just the logic how to acctually close this widget after when i’m no more aiming at it and my code has to be wrong there.
Your problem is you are trying to get data from a different path. The widget you are trying to get is from a divergent universe that never happened if you think about it. You need to save the widget into a variable when you create it, and then remove and clear it when you stop looking at the thing.
Idk i just tested with and without but it didn’t work. True no need to create a new one there.
I changed it to “get” my widget reference as you pointed but it is still not working and disconected the rest. Still same result widget gets created but it doesn’t close after…
I can awso try reverse the code and widget gets created when not aiming at the actor and when aiming it will awso not close. I so at least know that this looking at the actor or not looking at it isnt the cause because that is working. There must be some way to close this…
You run a loop but return no matter what. Without checking references you don’t even know how many widgets get created. You may have 100s of orphaned widgets sitting in the viewport and leaking memory. Widgets you cannot even remove.
Let’s say you run this script 60 times per second. You will have 59 overlapping widgets on top of one another in the 1st second of the trace because only the one added last gets removed. Admittedly, hard to tell what else is going on.
I just found out the same thing. I think this widget gets created in a loop every 0.2 sec because i have on tick node in the event graph that checks for this
Edit : Ok i changed the event tick to a node where i press a key and it works. Aiming at the actor and the widgets pop up on the screen - then looking away and pressing the key again removes the widget. Now how can i make this to work without the need of a key ? It should constantly run like on tick event. Is there anything i can do to make it work ? Was trying “Do once” node in the function but it bypasses it…
But it bypasses it as if it wasnt there. This emitter run non stop in loop so it must run the code after in a loop too creating many widgets. I tought when i aim at the actor it should fire Once and then when not aiming at the actor should reset it + close the widget. So next time by looking at it it can create a new wiget again and repeat. It seems it still fire non stop when aiming with do once node… Is this somehow flawed tactic to achieve what i aimed for ?
You have to check if the widget variable is valid first, only when the widget variable is not valid then you can use the create widget node,if it’s valid just use the add to viewport node.