分三步
1.UGameplayStatics::BeginDeferredActorSpawnFromClass 预生成actor
2.给actor变量赋值
3.UGameplayStatics::FinishSpawningActor 最终生成actor
FString strBPFileName = "/Game/UltraDynamicSky/SkyMode.SkyMode_C"; UClass* pClass = LoadClass<AActor>(this, *strBPFileName); if (pClass) { FActorSpawnParameters SpawnParameters; FTransform spawnTransform; CurrentSkyMode=Cast<AGSkyMode>( UGameplayStatics::BeginDeferredActorSpawnFromClass(GetWorld(), pClass, spawnTransform)); if (CurrentSkyMode) { CurrentSkyMode->LevelId=4; } UGameplayStatics::FinishSpawningActor(CurrentSkyMode, spawnTransform); }
标签:pClass,CurrentSkyMode,spawnTransform,actor,C++,生成,Actor,ue5,UGameplayStatics From: https://www.cnblogs.com/asksk/p/17877777.html