Hello @tranek, thanks again for this treasure of a repo!
While going through it for a new project I am working on, I found that the initialization part of the ASC might be redundant when the Owner and Avatar Actors are the same object which the ASC is a member of. The reason being the function below (as of UE 5.7.0):
void UAbilitySystemComponent::InitializeComponent()
{
Super::InitializeComponent();
// Look for DSO AttributeSets (note we are currently requiring all attribute sets to be subobjects of the same owner. This doesn't *have* to be the case forever.
AActor *Owner = GetOwner();
InitAbilityActorInfo(Owner, Owner); // Default init to our outer owner
// cleanup any bad data that may have gotten into SpawnedAttributes
for (int32 Idx = SpawnedAttributes.Num()-1; Idx >= 0; --Idx)
{
if (SpawnedAttributes[Idx] == nullptr)
{
SpawnedAttributes.RemoveAt(Idx);
}
}
TArray<UObject*> ChildObjects;
GetObjectsWithOuter(Owner, ChildObjects, false, RF_NoFlags, EInternalObjectFlags::Garbage);
for (UObject* Obj : ChildObjects)
{
UAttributeSet* Set = Cast<UAttributeSet>(Obj);
if (Set)
{
SpawnedAttributes.AddUnique(Set);
}
}
SetSpawnedAttributesListDirty();
}
This function belongs to AActor and is overriden by the ASC as it is by most component classes and the initialization already occurs here. As this function will run on both, the server and the client, it becomes unnecessary to have to call InitAbilityActorInfo on the ASC again, unless either the Owner and/or Avatar Actors have changed.
Do you think it would make sense to note this in the documentation in Section 4.1.2?
Hello @tranek, thanks again for this treasure of a repo!
While going through it for a new project I am working on, I found that the initialization part of the ASC might be redundant when the Owner and Avatar Actors are the same object which the ASC is a member of. The reason being the function below (as of UE 5.7.0):
This function belongs to AActor and is overriden by the ASC as it is by most component classes and the initialization already occurs here. As this function will run on both, the server and the client, it becomes unnecessary to have to call
InitAbilityActorInfoon the ASC again, unless either the Owner and/or Avatar Actors have changed.Do you think it would make sense to note this in the documentation in Section 4.1.2?