How to fix error Accessed None trying to read property K2Node_DynamicCast_AsThird_Person_Character .

My Reload function when I play and reload gun it show error.

This is error when reload.

Blueprint Runtime Error: Accessed None trying to read property K2Node_DynamicCast_AsThird_Person_Character from function: 'Reload' from node: Return Node in graph: Reload in object: Weapon_Base with description: Accessed None trying to read property K2Node_DynamicCast_AsThird_Person_Character

I try to use is valid like this but it show same error . How to fix it ?

Hi there, funny enough i have the exact same problem. Did u get to fix it by any chance? Sadly no one answered here :frowning:

The problem could be that ThirdPersonCharacter is not the pawn currently possessed by Player Index 0.

Can you share your BP?

1 Like

Hi! After searching for a solution for nearly 2h I was so frustrated that i tried random stuff.

I fixed the issue by splitting the Return nodes into 2 different Return nodes each for the two pipelines.

I have zero clue why it worked, i would like to know that.
And also i dont know if it brings me Errors in the future.

Anyway heres my new setup for the more or less same Code.
Only difference being the two pipelines went into the same Return node with 2 Outputs instead before.

And heres the function call

You can see the old pipeline in the lower “Secondary Weapons” Reload call.
Its the same as the one above now though.

EDIT: I do see the creator of this post not hooking up the second branch to the return again. Maybe they forgot.

Thank you!

The out bool parameter will try and get a value from the connected nodes even if those nodes are behind a branch. IMO you should have a return node connected to each Cast Failed to ensure it doesn’t hit a dead end when trying to get a value from a null source.

Thats a general guideline for the logic right? Because even if the cast fails the function is faulty and in my case, unwanted.

I still dont quite get why it didnt work before.

Also to answer the previous question, i only have one player Character - at least to my knowledge.

And the issue is replicated only by pressing R which is the trigger for that reload event. It doesnt fire anywhere else - since i used alot of Playerchar object refs.

Thank you so much for your time nonetheless! Have a nice day :slight_smile:

If none of you condition end up at a return node, the function should still work and the bool parameter should return false. So you do not HAVE to add an extra return, it’s just a suggestion for clarity sake.

The problem with the original image is that hes trying to get a value that seems to be later in the execution order.

In your prev example if the cast fails you should get the print and false on the bool, so should not crash from a null value since each return node and nodes associated with it are behind a check (the cast).

Hope it makes sense.

1 Like

ahh yea, i think i do get it, that makes sense. Thank you so much!