Hi,
I’m trying to set the tags of an Actor which I spawn via a template. But for some reason it doesn’t work. I first create a default object of the actor, add the Tags and than I assign it as a template to a FActorSpawnParameters. The parameters is than used to Spawn the actual object. But for some reason it doesn’t pick up the Tags I’ve set in the template.
(See code below)
Can anyone tell me the correct way of using a spawn template?
UObject* SpawnActor = Cast<UObject>(StaticLoadObject(UObject::StaticClass(),NULL, *BluePrintName));
UBlueprint* GeneratedBP = Cast<UBlueprint>(SpawnActor);
FActorSpawnParameters SpawnParameters;
AActor* HexActorTemplate = Cast<AActor>(GeneratedBP->GeneratedClass.GetDefaultObject());
const FString StringPrintf = FString(TEXT("{0},{1},{2}"));
const FString StringFormatted = FString::Format(*StringPrintf, { HexData->Location.X, HexData->Location.Y, HexData->Location.Z});
HexActorTemplate->Tags.Add(FName("Hexagon"));
HexActorTemplate->Tags.Add(FName(StringFormatted));
HexActorTemplate->Tags.Add(FName(Type));
SpawnParameters.Template = HexActorTemplate;
AActor* HexActor = GetWorld()->SpawnActor<AActor>(GeneratedBP->GeneratedClass, Location, Rotation, SpawnParameters);