better comments / cleanup

This commit is contained in:
Brandon Thomas
2021-02-17 05:40:44 -05:00
parent 4f9b8fc4f9
commit 74b73aad49
@@ -39,29 +39,22 @@ void ASpawningActor::Tick(float DeltaTime)
void ASpawningActor::Spawn() void ASpawningActor::Spawn()
{ {
// Spawn actor
// TODO(bt): This will memory leak.
ASpawnableActor* spawnedActor = (ASpawnableActor*)GetWorld()->SpawnActor(ASpawnableActor::StaticClass());
// Teleport actor randomly
// TODO(bt): Put this in front of the camera, or on the (camera -> player) arc!
float x = FMath::RandRange(-1000.0f, 1000.0f); float x = FMath::RandRange(-1000.0f, 1000.0f);
float y = FMath::RandRange(-1000.0f, 1000.0f); float y = FMath::RandRange(-1000.0f, 1000.0f);
float z = FMath::RandRange(-1000.0f, 1000.0f); float z = FMath::RandRange(-1000.0f, 1000.0f);
FVector location(x, y, z); FVector location(x, y, z);
FRotator rotation; FRotator rotation;
/*ASpawnableActor* spawnedActor = (ASpawnableActor*)GetWorld()->SpawnActor(
ASpawnableActor::StaticClass(),
NAME_None,
&location,
&rotation,
nullptr, // ??
false, // bNoCollisionFail
false, // ??
nullptr, // owner
nullptr // instigator
);*/
// TODO(bt): This will memory leak.
ASpawnableActor* spawnedActor = (ASpawnableActor*)GetWorld()->SpawnActor(ASpawnableActor::StaticClass());
spawnedActor->SetActorLocationAndRotation(location, rotation, false, 0, ETeleportType::ResetPhysics); spawnedActor->SetActorLocationAndRotation(location, rotation, false, 0, ETeleportType::ResetPhysics);
// We don't want to keep the actor around indefinitely since they may pile up unused.
// Optionally, we could maintain a queue and cull the oldest actors.
spawnedActor->StartDestroyTimer(10.0); spawnedActor->StartDestroyTimer(10.0);
} }