Download

Accessed None Trying to Read Property

Hi,

I keep getting this error in my message log saying accessed none trying to read property “Char”. Char is a variable referencing to my character blueprint. Here are some screenshots to help you understand what is happening:

bfa008ea5a5a6ed1089a5bac419793eeae2477bc.png

d8bd0858cd9996300dbaa62f4db43e32cf352df1.png

It would be more helpful if you showed us where you set the char variable. Don’t if this will help but when you set a variable in a class you just spawned or created it’s a good idea to put a delay in between just in case the executions are to fast and the the class wasn’t completely spawned. Just a tip.

1 Like

I never set the char variable in the widget blueprint (which is what is being shown in the second picture).

  1. You have to set the reference, even if you only have 1 class of that type. On the variable’s details pane set ‘expose on spawn’ and when you create the widget actually set the reference (it will be on the create node).

  2. Use of the IsValid node will prevent accessing none- it won’t help with situations like this (where the code will still never work), but it will prevent the code from throwing an error.

How would I go about setting the Char variable?

Blue Reference Variables are empty on default. Not like, for example, INTEGER variables, that are 0 or so on default.
They are used to save a REFERENCE to one instance of an Actor/Object in the World.

For example ONE of many spawned Players. But you NEED to specify which one you want to save. Otherwise it’s empty and otherwise you
get an Error.

You can make sure you only use the variable (access it) when it’s valid by using an “IsValid” node. Though that doesn’t solve your variable being empty.
When setting it to “Editable” and “Exposed on Spawn”, you can set it directly from the “Create Widget” node.

So now it’s your goal to find the actual object in the world that you want to reference.

If you have 0 idea about how to deal with that, then welcome to Object Orientated Programming :smiley:

Here is a good video by Epic Games, that might help you getting started:

https://www.youtube.com/watch?v=EM_HYqQdToE

Hey Exi, Why am i getting error from my player2, eventhough im promoting it to a variable, exposing on spawn and setting to editable? This is a issue that i’ve been struggling with since the beginning i started working with unreal 4.

This is inside my gamemodebp
access none.png

this is inside my characterbp, casting to the gamemodebp and printing the results -> player1 is fine, player 2 is none.
0973aa31f241b5f21de92bedac432cc9d0ee29ef.png

Thanks in advanced, My project is pretty reliant for me to able to correctly refrence each player. I’ve been using a work around for 6+ months and haven’t got around to fixing it, getting all actors from class and setting them via get inside my characterbp. Im assuming thats not the correct way to do it.
best regards, SamuelB

I think one of your object which supposed to be spawned by your Char was spawned on your level manually. So it is not connected to the player.