Hi All, I’m trying to get an int variable and TArray from an actor component.
In my blueprint function library I’m getting an actor by tag then getting reference to the Actor component on it.
void UFunctions_LIBBPLibrary::MatSelector_ChangeMat(FName Tag, int MatID, TSubclassOf<UActorComponent> Component)
{
UWorld* World = GEngine->GetWorldContexts()[0].World();
TArray<AActor*> FoundActors;
UGameplayStatics::GetAllActorsWithTag(World, Tag, FoundActors);
//works to get component
UActorComponent* FoundComponent = FoundActors[0]->GetComponentByClass(Component);
FString nname = FoundComponent->GetName();
UE_LOG(LogTemp, Warning, TEXT("%s"), *nname);
}
I want to change the material from the Tarray on the child component but I cant get the array from my reference to run the following.
auto* newmesh = FoundComponent->GetOwner()->FindComponentByClass<UStaticMeshComponent>();
newmesh->SetMaterial(0, ArrayFromComponent[MatID]);