how to clear widget display after ActorEventEndOverlap (RESOLVED with help from Kalakus )

I can clear the widget display when I leave overlap box with " remove all widgets " node. but then it removes my hud and everything. I just want to remove the specific timer widget.

Hello, you need to create a reference for every hud you display on the screen, with that reference you can interact with a specific widget and remove it from the viewport. You can also use IsValid with that reference for check if that widget object exist or not before trying to remove it.

Thanks ,how do I create a reference for my timer widget?

You need to do it where you create and display that widget, after the blueprint node “Create Widget” right click on the “return value” and promote it to variable.

for interact with it just drag it from the variables with GET, drag a pin and set an IsValid node, if is valid then you can use the “remove from parent” (if you are creating the widget outside the level blueprint you need to use a cast for use that reference, for example if you create the widget inside the PlayerController the on EndOverlap you need to Cast To PlayerController, and as object Get Player Controller, then you can get the reference you created previously)

ps:
it will work also without the IsValid node, but if for any reason that widget doesn’t exist that will generate an error.

its like this in a timer bp>>>>>>>>

overlaps are in the timer bp as well>>>>>>>>>>>

I recreated this with my UE4, picture attached. Hope this can help you.

ps:
you’re creating the widget inside a timer that is called 1 time per second, this is wrong, you need to create widget only one time outside the timer tick, you don’t need to call that so many time, one time is sufficient when the player enter inside the overlap and if you need to update the time counter or the damage on the UI you can bind the value from the widget itself.

i think you’re creating and showing too much time the widget and also this is a possibile cause that my example will not work, so take the create widget and add to viewport OUTSIDE the timer tick and place it on begin overlap.

I tried it like this and this but widget counter still wont leave when I exit the overlap box.

also I noticed even though I have the end overlap connected to "clear and invalidate timer by handle, it really doesn’t clear. it just stops where it is , and starts from there when I overlap again , instead of starting over. If I connect clear and invalidate timer by handle in the BeginOverlap side , no timer shows up, so it seems to work there.I mean generally , timer starts on BeginOverlap , if EndOverlap is connected to clear and invalidate timer by handle , it should clear it , wouldn’t it?

i think it doesn’t work because you’re using Create Widget and Add to Viewport inside the timer function, you’re creating and displaying more than one widget per second on the hub because the timer function is called 1 time per second when the player start overlapping the box, so i think you’re creating and displaying a LOT of widget on the same position.

so remove the Create Widget and Add to Viewport from the timer function and Add it after begin overlap, I need to go to work now, try this and let me know, if you can’t make it work I will try to replicate your blueprint more accurately.

I will try when I get home from work let you know, thanks for help. Another thing I did was copy and paste the overlap events onto my character. I needed to call the player get damage event from the character to kill him when the timer runs out. I originally wanted to get all the timer logic away from the character so i could leave the “Max Breath “ variable public and set it to different times when i pit a blueprint out .but couldn’t figure out how. Its weird , i have nothing referring to pause a widget, but thats essentially what it does. Timer starts counts down when i enter overlap .When i exit overlap box , timer stops/pauses ( but stays on screen), re enter overlap box timer starts again from wherever it paused. Timer reaches 0 , character dies.

I think you can call directly Apply Damage from timer and from your character you can call the event Any Damage, separate things is the right approach, you need to understand that you can cast and call reference to almost anything (with some exception) from one blueprint to another, I will edit my example with a more complete version when I go home, I will recreate the timer and show you how to apply Damage directly from the timer.

I tryed to recreate your situation, i tested with this setup and works perfectly, let me know.

When the player enter the overlap the widget will be created and displayed, also the timer start, when the timer reach 7 seconds (you can change this value) the player will be killed, if the player leave the overlap the timer will be resetted and the next time will start again from 0, i added a simulate physics for testing purpose, you don’t need it if you don’t want it.

With this example you can see this awesome function called Get all Actors of Class, with this you can call any function or event inside the Timer Actor or any Actor, i’m sure you love it :slight_smile:

Wow , thanks , i’ ll try it when i get home. The reason i called “player get damage “ from the character is then it ties right into the ragdoll death ,dissolve , and respawn at checkpoint automatically.

So your doing the entire thing (except the physics part) in the timer bp?

Yes but the AnyDamage is handled in the character blueprint.

so a couple things. (I am on lunch for a few more minutes), I set it up like you have it , I need to get from my character “player get damage event” , this would go where your “apply damage” function is. but I cant get it from the timer blueprint? I can when on character because it is on the character. also the timer widget display does not start counting when I begin overlap. , just sits at the original setting. but the print string does start counting down. otherwise the widget number pops up on on begin overlap , then disappears correctly when I end overlap. I must be missing something yet. will look again when I get back shortly.

if you want to send me some screenshot so i can see how you setup it.

in the first one I cant get the "player get damage " event from character so that node is not there. the 2 others are the other parts in the event grap

h. my timer counts down from 45.

sorry my screens got mixed up, heres the other 2.