Whenever you receive that error, try adding the “Isvalid” macro to prevent it from continuing an execution sequence with a blank value. It removes the error, but will not necessarily solve the problem.
The error occurs because you are trying to perform some sort of function that relies on a variable, but the variable isn’t set when you run your function so it returns that error to let you know you haven’t set a value to the variable. You can also solve this by considering the sequence of events.
For example, if you attempt to do something with a widget, but you haven’t yet added that widget to the viewport or set the widget reference before you start your function, it will return with trying to read none. If you change the sequence so that you set the widget reference before running the functionality, it will work.
So I was following this tutorial for setting up character movement and I encountered the error below. I checked ten times and I am sure I did everything the same as him. Can somebody help me? If you need more screenshots just ask. Here is the link of the video: [Unreal Engine 4 - Sprinting and Stamina Bar (Part 1)
][1]
I refreshed and added the player controller but nothing changed. Something which I forgot to mention before was that the widget does appear on screen but it just doesn’t work. Out of curiosity, is the blueprint from the tutorial supposed to work or is it outdated?
Welp, things just got weirder. I looked at the tutorial and decided to get rid of the one thing which I did different, the border and now it works with the only problem being that I am STILL getting the error message. Unreal engine is hard…
In my experience of adding a widget to the viewport, I had to add a small delay node before actually calling the add to viewport node. I think this is because it tries to add the widget to the viewport the exact tick the character comes into play, but at that time the character isnt fully initialized and isn’t ready to be refereneced by other lines of code.
TL:DR: Add a .5 second delay before calling the add to viewport node.