Accessed None "K2Node_DynamicCast" Error

Hi there, sorry to burden y’all with my troubles, but I’d like some advice.

To make a long story short, I’m implementing my very first AI, a basic little dude who runs from A to B and back again, and I’m getting the dreaded Accessed None error in my log. The AI guy is relying on the same AnimBP as the player, and said AnimBP has a few Casts to the player blueprint. The error message suggests the problem is there, in the AnimBP, but I’m just not seeing anything.

I set up some IsValid? checks, because I’ve read those are useful for handling these Accessed None errors, but I’m still getting them.

Broadly, I have two questions: are there any tips for dealing with these errors, and how do y’all set up multiple characters who reference the same AnimBP? Or do you make multiple copies of the same AnimBP to get around this issue?

Thanks in advance and have a great weekend, and a happy Mother’s Day too.

Can you post screenshots of your blueprints?
The information is not being retrieved. Most likely a bad cast or the method you are using to call the information.

Show where you do the call, and what is being called.

Basically I set up a notify for whenever the character’s feet touch the ground. This way the character’s footsteps sound different depending on the surface they’re traveling upon. The thing is, everything seems to work fine for the AI dude – his feet call the appropriate sound effects and so forth.

But according to the error message, this is the source of the Accessed None issue.

Hi.
It looks ok. Can you post a screenshot of the one pawn owner and the other, what is called etc.

I am a bit trapped in art today so i might be wrong here but check if you can replace with try get pawn owner with something else?
Doubt you can though.

Can you show how you do the cast… some more information on how you doing it might help us spot the issue

Thanks for getting back to me. Here’s the cast in the Anim BP:

It comes out of the Update Animation node. But this only affects the player character, so I don’t understand why the AI dude would cause a problem.

I’m not sure what you mean by the rest. Do you want me to post a screenshot of the construction script for the two characters? One – as you can see above – is simply the ThirdPersonCharacter blueprint from the ThirdPerson template, and the other is a copy called AI_Agent.

Hi.

ok i must admit i am a bit confused. You have the player, and the enemy both using the same AnimBP and the same Character BP.
Are both of them using ThirdPersonCharacter blueprint?

One thing to consider is setting up a simple Blueprint interface and call that. I have had more success with this. I share a AnimBP with 2 characters and i share a controller blueprint with 6 characters.

To do this is fairly easy.
Create the Blueprint Interface and make sure under defaults that your BP’s are using it by adding it.
Add a function in the blueprint interface. Do not give it an input or a output. Just add it there and name it to something you will remember.

From the Try get pawn owner you call that interface message.
And in your character blueprint you add the interface event. Just make sure it states from bpinterface or something like that.

From there in the character blueprint you can do the stuff that was added after the cast.

I also had some issues like you where doing a cast to shared stuff caused issues but the interface events sorted that out for me.
Let me know if you need more help or clarification.

Good luck

I’ve never heard of blueprint interfaces. Sounds promising!

Setting it up like you described, though, has yet to fix the problem. Here’s what I’m doing in the AnimBP:

I’m hoping I misunderstood you and made a mistake. For both characters – the player and the AI – I’m calling the BasicCharacter interface function at the end of their construction scripts.

Hi.
You need to execute it… or i mean have the event do stuff.
Hmm not sure what you have in the construction script.

This is what i do… i dont cast at all because that caused some issues for me.

Anim Notify does stuff and tells its owner to run that event
05aa131b4c951dcadeacf2a187efce476db6c554.jpeg
The owner / Pawn / Character then fires that event and does what it needs to do. Set bools or run other events etc.
80f0f6c0a111f5ae36c38bc4ce9665da1137ced0.jpeg

This sounds very interesting, but I’m afraid it’s going over my head.

If I’m understanding you right, this is a method for containing a host of events that multiple blueprints can access? And you can call these events from within an AnimBP without casting to anything?

Is there a limit to how many events I can create in an interface? The graph is greyed out and uneditable for me, so I’m curious.

Hi.

Don’t stress. It took me a long time to snap Blueprint Interfaces. They were just confusing as hell for me.
I am not sure what the limits are. My one interface currently contains over 50 functions.

Here is a rundown of the BPI thing.

It will be greyed out because you do not directly work on the BPI (Blueprint Interface)
It is basically a shared variable or like you said above.

Like your screenshot you called the message. But the actual red event box coming from the BPI needs to be on your character blueprint now.
If that is present then technically it should fire without issues.

When you create it do not add an output in the BPI for that specific thing or it will remove your ability to create an event for it.

The free ebook Master blueprints is what got me to understand BPI’s. EPics videos just confused me more when it came to BPI

Good luck man

I still getting the same error “K2Node_DynamicCast_AsThird_Person_Character” more exactly in a branch after this. I was trying to make some enemies spawn. The first one works ok — no error — but the others do not apply the damage and after close the simulation, this error come…Some ideia of what I need to do?