Need help with AI Perception implementation in CPP

Hey everyone.

I am working on an AI Perception System in CPP with the following function bound to OnPerceptionUpdated.

r/UnrealEngine5 - Need help with AI Perception implementation in CPP

r/UnrealEngine5 - Need help with AI Perception implementation in CPP

However i am getting a crash whenever i try to start playing in editor. I am using UE5.3.

The stack trace is as follows

r/UnrealEngine5 - Need help with AI Perception implementation in CPP

The crash points to this line in CanSenseActor:

for (FAIStimulus& CurrentStimulus : ActorPerceptionInfo.LastSensedStimuli)

Can someone please help me understand what i am doing wrong? Every usage i see is similar to this but i keep getting crash and am at my wits end.

Thanks :slight_smile:

You should run this in the debugger, which lets you look at the variables in question.

Maybe GetPerceptionComponent() returns NULL?
Maybe LastSensedStimuli is not present?
Use “Attach to Process” if you need to debug the game while “running in editor,” or use the launch mode that starts the game as its own process and debug that.

Seems to be an issue with the stack trace line number display. It was a null pointer dereference issue but with another line.
I was calling SenseClass->GetClass() without a nullcheck.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.