I would like to get clarification on the observation I noticed during my AI/BehaviorTree/Blackboard usage:
Based on my experiment, It seems that when a blackboard referenced actor (object) is destroyed externally (triggered by DestroyActor somewhere else), the said blackboard object (referencing the actor) automatically becomes un-set, without me explicitly resetting that reference to none. Is this observation correct and the intended behavior that I can rely on as “officially supported”?
The following code snippet as found from BlackboardKeyType_Object.cpp seems to confirm the speculation:
UObject* UBlackboardKeyType_Object::GetValue(const UBlackboardKeyType_Object* KeyOb, const uint8* RawData)
{
// RawData can be NULL if the key is corrupted by bad data, such as if someone has duplicated a key in a derived
// blackboard. We must handle that bad data case gracefully. It's likely that we need to handle this for
// all blackboard key types, so possibly GetValueFromMemory should handle the NULL case instead. But for now I'm
// just fixing the case I came across.
if (RawData == NULL)
{
return NULL;
}
FWeakObjectPtr WeakObjPtr = GetValueFromMemory<FWeakObjectPtr>(RawData);
return WeakObjPtr.Get();
}
bool UBlackboardKeyType_Object::SetValue(UBlackboardKeyType_Object* KeyOb, uint8* RawData, UObject* Value)
{
TWeakObjectPtr<UObject> WeakObjPtr(Value);
return SetWeakObjectInMemory<UObject>(RawData, WeakObjPtr);
}