Remove a Widget

So, I have this problem where my game runs fine for about a minute until the game ends, and it gives me: UE4 blueprint runtime error: accessed none trying to read property… I looked for answers and tried the IS VALID node. That didn’t seem to work. any ideas?

I’m trying to make a breathing widget appear when I start swimming in water, and then go away when my character is not swimming. Maybe if you have alternative ideas on that too…

.

So, not sure what your exact problem is, if it is that you cannot get it to appear, then, you should probably Add to viewport the Set reference prior to playing that widget animation.

Now, for your Under Water variable being null. Are you trying to access this after or before you Quit Game? I mean, I’m confused on why it’s quitting the game, but maybe it’s just your debug logic.

As long as you are not calling that Event Swimming Disabled prior to its creation up top (Event Swimming Enabled), then you should be fine.

So, tell me, does your widget appear or not?

Well first off, you can upvote and set as resolved my answer please.

Secondly, you just don’t call Swimming Disabled on begin play. Or you can use a boolean to know if the player is swimming or not. And check that before calling stuff. If player not swimming, bool is defaulted to false, good to go. Player swimming, set bool to true, now you can call Swimming Disabled because player WAS swimming and then set that to false now at the end because Player is not swimming.

Basically use the bool to make sure you can call the Swimming Disabled or not. And you won’t have any issues.

Yea that’s what it is then. I begin the game with Event Swimming Disabled. (because my character is not in the water to start). I’m not having problems with the viewport. The game just crashes with the logic I laid out in the pic. I used the quit game not as a debug but as a part of the game. (when the player swims in the water for more the 45 seconds, he dies, game ends. you know the classic underwater widget).

So… I guess it’s cause I called the disable first, how do I fix this? Or can I? maybe there is a better way to bring up a widget and get rid of a widget?

sorry :slight_smile: its been awhile

I think the logic is right for the most part… I’m looking into some other things. I debugged by setting the delay to 5 seconds. And then the game would quit 5 seconds after going into the water once. I guess it’s something wrong with the whole formula. I think I can figure it out. The IS VALID node worked. Before I was getting null messages. I thought that was the problem. Where as now, it’s just that the logic is following straight to quit game

Basically the game reads <<< When you enter the water, pop up a widget, countdown to 5 seconds and then end the game. If you leave the water, get rid of the widget. >>> I never told it to reset the end game function. It just finishes up the logic. Any suggestions? I’m just learning off of YouTube. I would imagine I could use some Flow control, but I am not familiar with all of those functions. thanks for all of your input so far…