Behavior Tree "Gotchas"

Bit of a long shot as this is an old thread but thought I’d see… I just upgraded to 4.25 preview 7 and I’m having issues with AISystem.cpp. In particular the registering and unregistering of components.

The *check *at the bottom always fires now and the ensure sometimes fires. It’s hard to make out what’s going on as values are optimized away. This wasn’t occurring in 4.24.

For the *check * I think it’s reference to an the AI actor controller hanging around. Or maybe it’s not being removed by RemoveSingle??

Feedback: I quite like the AI system but I’m ready to ditch it. It’s by far the biggest time sink in debugging issues and just getting it to work for this project. I can see a lot of love and thought was put into it but when using it in anger… it’s hell.



void UAISystem::UnregisterBlackboardComponent(UBlackboardData& BlackboardData, UBlackboardComponent& BlackboardComp)
{
    // this is actually possible, we can end up unregistering before UBlackboardComponent cached its BrainComponent
    // which currently is tied to the whole process.
    // @todo remove this dependency
**ensure(BlackboardDataToComponentsMap.FindPair(&BlackboardData, &BlackboardComp) != nullptr);**

    if (BlackboardData.Parent)
    {
        UnregisterBlackboardComponent(*BlackboardData.Parent, BlackboardComp);
    }
    BlackboardDataToComponentsMap.RemoveSingle(&BlackboardData, &BlackboardComp);

    // mismatch of Register/Unregister.
**check(BlackboardDataToComponentsMap.FindPair(&BlackboardData, &BlackboardComp) == nullptr);**
}