Hey so I was messing around with the AI Perception System in blueprint and i’m getting a really weird issue. Most of the time when I call the Register Source blueprint node it works fine. However after a little while (usually after restarting the editor a few times) the Register source nodes seem to break. They trigger a breakpoint here at the ensure function:
void UAIPerceptionSystem::RegisterSource(FAISenseID SenseID, AActor& SourceActor)
{
ensure(IsSenseInstantiated(SenseID));
SourcesToRegister.Add(FPerceptionSourceRegistration(SenseID, &SourceActor));
}
The only way to get around it once it starts doing this is to completely recreate the blueprint. Even if I remove the node and add it back the problem persists until I make a new version of the blueprint. So far its done this with blueprints based off of pawn, character, and several other custom c++ ones that are also based off of pawn or character. Here is a link to my call stack when I hit the breakpoint: http://pastebin.com/MvNSafaG
Here is the actual error that crashes the editor: Array index out of bounds: 255 from an array of size 1
Not sure if its related but also sometimes when I get this issue the node will change from requiring the sense class and the target object to one that also requires a world context.
Edit: So after talking with some people on the UnrealEngine IRC channel Ashyre figured part of it out for me. Essentially I had to make some changes to the AIPerceptionSystem.cpp
On line 399 I removed the const
Then I insterted a new line at 403 SenseID = UAISense::GetSenseID(Sense);
The end result being:
FAISenseID SenseID = UAISense::GetSenseID(Sense);
if (AISys->GetPerceptionSystem()->IsSenseInstantiated(SenseID) == false)
{
AISys->GetPerceptionSystem()->RegisterSenseClass(Sense);
SenseID = UAISense::GetSenseID(Sense);
}
However, after some more experimentation I realized that while this didn’t actually fix the problem it made it reproduce regularly. Essentially whenever I restart the editor the Register node changes and the game crashes with this call stack: http://pastebin.com/3GbKq2VH
I have tried attaching stuff to the world context but it doesn’t fix anything.
Thanks,
-Chris