"Accessed None Trying to Read Property" for Triggers

While trying to set a part of a game in which the player must correctly answer three puzzles in order to proceed, I have been trying to set the program to work under one of eight particular conditions, initially using Booleans. When I compiled, UE didn’t give me any complaints. So I did a test run.

After I did and pressed Escape to finish, a Message Log popped up, showing “Accessed None Trying to Read Property.” It’s griped at me every time I try to use a branch to make the program work under certain conditions. Even when I try to use an integer-based counter, the program gripes at me.

To be more specific, I’m trying to get the program to retrieve information from three widgets for each correct or incorrect answer chosen. Each widget is a puzzle to solve, with multiple choices. If the right answer is picked, then its respective integer is raised to 1; otherwise, the integer stays at 0. But, even with one widget and its integer referenced, UE gripes at me for doing so and for using a branch. What might the problem be?

(Oh, and ignore the “(None)” on the trigger overlap box. It has a name in the actual program.)

EDIT: The error only occurs if the player does not answer the widget’s question at all. I’m also trying to set the program to act as if all answers are wrong if the player doesn’t even attempt to answer the widgets’ questions.

can you show the part where Puzzle2Screen get set?

Here you go:

i need to see the part where you set Puzzle2Screen, after you create the widget, it should look like the picture below.

if you never set the variable, then when you “get” the variable, it will be a nullptr, you can google if you need more info about what that means

You mean like this?

yea, so I noticed you have OnActorBeginOverlap for both. Are these 2 separate actors you’re showing here?

Where does the widget get created and where does the Puzzle2 integer get pulled from?

Yes, they are separate box triggers. The widget appears when the player approaches the trigger controlling the widget. By that, I mean the player walks up to a thin cube made to look like a screen. When he does, the widget appears as a clickable window and the player will have to select one of three answers. I can make a clip of that, if you want.

so if you want to move data between the 2 triggers, you will need to pass that widget reference to the second trigger.

There are several ways of doing this. You could keep the reference on the character, so that when the character walks to the next trigger, the trigger can just read whatever number you have stored on that character’s widget, like the pictures below.

the problem is, when you do RemoveWidget, the widget will get destroyed by garbage collection at some point, and that might happen while you’re walking to the next trigger, so the reference would be nullptr again.

the best way would be to store an integer on the character, call it MyPuzzleSolution2, then set that equal to Puzzle2 integer when the player makes a selection , then on the second trigger, get MyPuzzleSolution2 from the character

How were you able to create a node that allows me to both promote the widget to a variable and set the character (TopDownCharacter, in this case) as the related target, like in the first image you shared?

in my character blueprint, i already have an empty variable with the type UserWidget, but instead of UserWidget, you need to make it Puzzle2Widget type

image

image

Like this?

yea, but remember, you cant remove the widget from your viewport, otherwise it gets deleted, you would have to set visibility to hidden

So I should set the widget to hidden instead of removing it, after the player makes a choice? What about if the player ignores the puzzle and tries to press the switch that the second trigger controls?

i’m not sure, it hard to visualize

also, i will be leaving for a while, i can answer again tomorrow.

Good luck :slight_smile:

Do you think I should upload the project file on Google Drive and share a link? Or should I just get the blueprints relevant to this problem and share a clip or two?

I’ve just tried having the level BP initialize the Boolean variables for the puzzle widget before the widget is even triggered; and, the widget itself is set to make the Boolean true if the correct answer is chosen. Still, when I test-run, hit the trigger to test the branch and press Escape, I still get an “Accessed None trying to read property Puzzle2Screen.”

So, initializing the related variable early on doesn’t seem to work.

I think I have an idea. I will attempt to set the switch button with the branch to “power up” only if the three widget puzzles in the demo have been answered, right or wrong. This means I’ll have to use integers. This means having to cast to the actor with the integer and setting it to a number.

Here is this newer thread link I wanted to share with you: Widgets and Level Sequences