random locations

This commit is contained in:
Brandon Thomas
2021-03-08 23:58:33 -05:00
parent 2f0ad5f419
commit e31a9c9005
@@ -11,14 +11,22 @@ FVector ULocationLibrary::GetPlayerLocationWithOffset(UObject* worldContext,
float x, float y, float z) float x, float y, float z)
{ {
FVector playerLocation = GetPlayerLocation(worldContext); FVector playerLocation = GetPlayerLocation(worldContext);
return playerLocation; FVector newLocation(
playerLocation.X + x,
playerLocation.Y + y,
playerLocation.Z + z
);
return newLocation;
} }
FVector ULocationLibrary::GetPlayerLocationWithRandomOffset(UObject* worldContext, FVector ULocationLibrary::GetPlayerLocationWithRandomOffset(UObject* worldContext,
float minX, float maxX, float minY, float maxY, float minZ, float maxZ) float minX, float maxX, float minY, float maxY, float minZ, float maxZ)
{ {
FVector playerLocation = GetPlayerLocation(worldContext); float x = FMath::RandRange(minX, maxX);
return playerLocation; float y = FMath::RandRange(minY, maxY);
float z = FMath::RandRange(minZ, maxZ);
return GetPlayerLocationWithOffset(worldContext, x, y, z);
} }
APawn* ULocationLibrary::GetPlayerPawn(UObject* worldContext) APawn* ULocationLibrary::GetPlayerPawn(UObject* worldContext)