mirror of
https://github.com/storytold/EventCenterPlugin.git
synced 2026-10-09 00:09:42 +00:00
this spawns near the player, but physics are borked
This commit is contained in:
@@ -43,15 +43,30 @@ ASpawnableActor* ASpawningActor::Spawn()
|
|||||||
// TODO(bt): This will memory leak.
|
// TODO(bt): This will memory leak.
|
||||||
ASpawnableActor* spawnedActor = (ASpawnableActor*)GetWorld()->SpawnActor(ASpawnableActor::StaticClass());
|
ASpawnableActor* spawnedActor = (ASpawnableActor*)GetWorld()->SpawnActor(ASpawnableActor::StaticClass());
|
||||||
|
|
||||||
|
// Get player location
|
||||||
|
FVector playerLocation = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation();
|
||||||
|
|
||||||
|
|
||||||
// Teleport actor randomly
|
// Teleport actor randomly
|
||||||
// TODO(bt): Put this in front of the camera, or on the (camera -> player) arc!
|
// 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(-100.0f, 100.0f);
|
||||||
float y = FMath::RandRange(-1000.0f, 1000.0f);
|
float y = FMath::RandRange(-100.0f, 100.0f);
|
||||||
float z = FMath::RandRange(-1000.0f, 1000.0f);
|
float z = FMath::RandRange(-100.0f, 100.0f);
|
||||||
|
|
||||||
|
FVector location(
|
||||||
|
playerLocation.X + x,
|
||||||
|
playerLocation.Y + y,
|
||||||
|
playerLocation.Z + z
|
||||||
|
);
|
||||||
|
|
||||||
FVector location(x, y, z);
|
|
||||||
FRotator rotation;
|
FRotator rotation;
|
||||||
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.
|
// 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.
|
// Optionally, we could maintain a queue and cull the oldest actors.
|
||||||
|
|||||||
Reference in New Issue
Block a user