From e31a9c9005cbc58c8cdc06b466b02c42b297bb5c Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 8 Mar 2021 23:58:33 -0500 Subject: [PATCH] random locations --- .../Private/LocationLibrary.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/ActorSpawningPlugin/Private/LocationLibrary.cpp b/Source/ActorSpawningPlugin/Private/LocationLibrary.cpp index 71cbe88..d16e13d 100644 --- a/Source/ActorSpawningPlugin/Private/LocationLibrary.cpp +++ b/Source/ActorSpawningPlugin/Private/LocationLibrary.cpp @@ -11,14 +11,22 @@ FVector ULocationLibrary::GetPlayerLocationWithOffset(UObject* worldContext, float x, float y, float z) { FVector playerLocation = GetPlayerLocation(worldContext); - return playerLocation; + FVector newLocation( + playerLocation.X + x, + playerLocation.Y + y, + playerLocation.Z + z + ); + return newLocation; } FVector ULocationLibrary::GetPlayerLocationWithRandomOffset(UObject* worldContext, float minX, float maxX, float minY, float maxY, float minZ, float maxZ) { - FVector playerLocation = GetPlayerLocation(worldContext); - return playerLocation; + float x = FMath::RandRange(minX, maxX); + float y = FMath::RandRange(minY, maxY); + float z = FMath::RandRange(minZ, maxZ); + + return GetPlayerLocationWithOffset(worldContext, x, y, z); } APawn* ULocationLibrary::GetPlayerPawn(UObject* worldContext)