Why isn't FindComponentByClass() finding a class?

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?

Try to use this

  TArray<UBaseSpawnNode*>  SpawnNodes;

MyActor->GetComponents(SpawnNodes);

 if (SpawnNodes.Num() > 0)
{
TempNode = SpawnNodes[0];

}

Hmm, that’s weird-it compiles fine, and I verified the actor this runs on has children with the node component, but SpawnNode is still empty after this executes.

Oh wait, I’m a moron, I had a typo- that works perfectly!!! Thank you very much :slight_smile: