I have a UActorComponent UBaseSpawnNode, and I’m trying to iterate through a list of actors, check if each actor has any children with a UBaseSpawnNode component, and add any nodes it finds to a TArray:
GetAttachedActors(propList);
for (int i = 0; i < propList.Num(); i++){
UBaseSpawnNode* tempNode;
tempNode = Cast<UBaseSpawnNode>(propList[i]->FindComponentByClass(UBaseSpawnNode::StaticClass()));
if (tempNode!= nullptr){
spawnerList.Add(Cast<UBaseSpawnNode>(propList[i]));
}
}
This compiles correctly, but when I give my test object two children, one of which has a UBaseSpawnNode component, propList correctly contains both items, and spawnerList has one index, but it’s value is listed as “None”: in spite of correctly detecting the presence of the node, it fails to correctly add a pointer to its list. Is there an obvious mistake in my procedure?