Accessed none trying to read property

Hello,
I was trying to make my ThirdPersonCharacter crouch in AnimBP and when I connect nodes and hit play everything works fine but when I exit playmode I get bunch of these errors:
Error Blueprint Runtime Error: Accessed None trying to read property K2Node_DynamicCast_AsThird_Person_Character from function: ‘ExecuteUbergraph_DaveAnimBP’ from node: Set IsCrouched in graph: EventGraph in object: DaveAnimBP with description: Accessed None trying to read property K2Node_DynamicCast_AsThird_Person_Character

I explain what this error means on this other Answerhub post.

Instead of calling the CastToThirdPersonCharacter function node, use the CastToThirdPersonCharacter macro that provides IsValid and IsNotValid execution pins. Then only set IsCrouched if the cast IsValid

Hello PikaBoo112,

This error means that the As Third Person Character pin is returning NULL, which means that the cast is failing.

I’d recommend using a Print String and printing the Return Value of Get Pawn Owner in order to see what that node is returning, which will allow you to begin to debug where the issue is inside of your blueprint logic. Also, it is important to use a Branch node off of the Success pin to determine whether or not the Cast was successful before attempting to use the result of the cast, or this could cause issues or even a crash down the line if the result is a null value.

Have a great day