첫번째 방법
FTransform SpawnTransform(SpawnRot, SpawnLoc);
AMyCharacter* Character = world->SpawnActorDeferred<AMyCharacter>(ActorClass, SpawnTransform);
if (Character)
{
Character->SetupFunction(... params ...);
Character->FinishSpawning(SpawnTransform);
}
두번째 방법
FTransform SpawnTransform(SpawnRot, SpawnLoc);
AMyCharacter* Character = Cast<AMyCharacter>(UGameplayStatics::BeginDeferredActorSpawnFromClass(this, DeferredActorClass, SpawnTransform));
if (Character != nullptr)
{
Character->SetupFunction(... params ...);
UGameplayStatics::FinishSpawningActor(Character, SpawnTransform);
}
- SpawnActor 호출 시 Constructor와 BeginPlay 모두 트리거
- SpawnActorDeferred 호출 시 Constructor만 트리거
- BeginPlay는 FinishSpawning 이후 트리거