Any help with "Accessed None" error

so, i have a “weapon_blueprint” that contains the “debug” Public variable

im giving the weapon to a “player_blueprint”, the “weapon_blueprint” is saved in Public variable withing the “player_blueprint”

In the “player_animation_blueprint”, im calling “debug” trough “player_blueprint”=>“weapon_blueprint”

The result is:

Blueprint Runtime Error: “Accessed None trying to read property GunEquiped”. Blueprint: Player_anim Function: Execute Ubergraph Player Anim Graph: EventGraph Node: Print String

im calling “debug” trough “player_blueprint” and it’s ok

help plz

thanks, this will help

It sounds to me like your player_animation_blueprint is attempting to call up your debug function before the weapon_blueprint variable is set on the player_blueprint actor.

In other words, the weapon_blueprint variable on your player blueprint is still null (not yet set) when player_animation_blueprint is trying to access it.

This is a very common issue. You just need to ensure the weapon_blueprint variable is set before calling your debug function (or any other function that needs to access that variable).

When is your debug function being called right now? Is it on BeginPlay()? If so, try adding a Delay node to cause your debug function to wait, say, 0.5 seconds before executing. Or you could use a keyboard event to trigger your debug function. Either way, you want to allow your player_blueprint enough time to put a value (technically, a reference) into its weapon_blueprint variable.

One way to always handle this problem, if and when it arises, is to use the Is Valid? blueprint node (the one with the execution pin is especially handy). You can use this node to ask the variable, “Are you null or not?” before attempting to do something with it. If null, you can set the value right there and continue on. If not null, great, just carry on execution.

It’s good to get into a habit of using nodes like Is Valid? to reduce the occurrence of issues like this. Eventually, you won’t even think about it, and the simpler things will just work. (Of course, at that point, it’s the more complex stuff that becomes a challenge. But that’s part of what makes programming and game development so fun!)

Anyway, I hope this makes sense and helps you move forward. Good luck!