Okay I have a timer that starts as I pick up a collectible item, but no matter what I do, when the timer hits 0, the 0 stays on the screen…
It is supposed to destroy my object, and start a timer that displays on the screen.When the timer hits 0 I want it to remove the timer widget from the viewport. The problem is, the 0 stays on the screen. Any ideas?
It turns out the problem was that I was making 20 widgets and then only deleting one. My solution was to add a delay node that would delay the sequence by one second, and then remove the widget as the next one was being created. So the timer would say 20, and 1 second later, the 20 would be deleted at the same time as the 19 appeared on the screen, giving it a seamless transition in a timer look-alike.
But it all works correctly until it comes to removing the widget. Everything is working, but when the timer hits 0, the 0 stays on the screen. I just replaced the function part with a set timer by even node, and it did the same thing.
Take a look at your SetTimerByFunctionName node, the 1st param it takes is called Object, you need to pass something into that. Drag off that pin and type Self. That’s what you need.
The problem, I think, is that SetTimerByFunctionName doesn’t know what object that function lives on. It may be obvious to you that the MustartdTime function lives on 2DSideScrollerCharacter but it doesn’t know that
the only other thing I can think of is something is wrong w/ your MustardCountdown decrement logic. Can you post that? Might be better to use the NearlyEqual node instead of <=. Floats can be funny
if branch false, you create widget and add it to viewport, but if branch true you attempt to remove from parent widget which is not created, output of create widget function. It doesnt have any sence.
I believe you should even have log warning messages about input of remove from parent not being valid, check output log.
The timer is counting down. If the timer is above 0 it goes through the false branch and creates the widget that displays the countdown. Once the timer hits 0, it goes through the true branch, and since the widget was created from the false branch, there is a widget to remove. It just doesn’t remove it and the 0 sits on the screen.
It’s in the original picture up there… I somehow deleted the line that displays the image but the link to view it is still there. Basically, every 1 second the set timer node calls the MustardTime event. The mustard time event subtracts 1 every time it is called, which is every second, which is how the timer counts down. As the timer is counting down, while it is above 0 the branch is false, so it creates the widget. Once it hits 0 it sends a signal to true where it is supposed to erase the widget. The problem is, it doesn’t erase (I ran the game with the bueprint open so I could see the signals. It DOES send a signal down the true path, it just doesn’t remove the timer widget from the screen).
wait a sec, you’re not storing the widget you’re creating. You can’t hook the creation up to the remove node. Store the widget as a variable when you create it and remove that from the parent instead
I see what you are saying, how would I go about doing that? (I’m still a noob when it comes to this. I’m trying to learn by making a 2d scroller that isn’t going so well haha)
Right click ReturnValue on the CreateMustardTimerWidget node and select Promote to Variable to create a variable and then fix your execution line if needed. It should automatically create a setter for IIRC
Drag that variable out onto your graph and click Get to get it. Hook the get one up to RemoveFromParent and unhook the other one from RemoveFromParent
Yep, that’s right. Now you need to see how many time your calling the false branch of that function before you call the remove. I have a suspicion that you’re creating >1 widget.
Put a break point on both the AddToViewport and RemoveFromParent nodes. see how many times AddToViewport is called before RemoveFromParent is called.