mirror of
https://github.com/storytold/ActorSpawningPlugin.git
synced 2026-10-09 00:09:44 +00:00
wip location manipulation static functions
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
#include "LocationLibrary.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
FVector ULocationLibrary::GetPlayerLocation(UObject* worldContext)
|
||||||
|
{
|
||||||
|
APawn* playerPawn = GetPlayerPawn(worldContext);
|
||||||
|
return playerPawn->GetActorLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector ULocationLibrary::GetPlayerLocationWithOffset(UObject* worldContext,
|
||||||
|
float x, float y, float z)
|
||||||
|
{
|
||||||
|
FVector playerLocation = GetPlayerLocation(worldContext);
|
||||||
|
return playerLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector ULocationLibrary::GetPlayerLocationWithRandomOffset(UObject* worldContext,
|
||||||
|
float minX, float maxX, float minY, float maxY, float minZ, float maxZ)
|
||||||
|
{
|
||||||
|
FVector playerLocation = GetPlayerLocation(worldContext);
|
||||||
|
return playerLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
APawn* ULocationLibrary::GetPlayerPawn(UObject* worldContext)
|
||||||
|
{
|
||||||
|
APawn* playerPawn = UGameplayStatics::GetPlayerPawn(worldContext, 0);
|
||||||
|
return playerPawn;
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Unreal Core
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "UObject/NoExportTypes.h"
|
||||||
|
|
||||||
|
// Function Library
|
||||||
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
|
|
||||||
|
#include "LocationLibrary.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper functions for obtaining and manipulating locations.
|
||||||
|
* The world context is automatically injected.
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class ACTORSPAWNINGPLUGIN_API ULocationLibrary : public UBlueprintFunctionLibrary
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
// The player's location
|
||||||
|
UFUNCTION(BlueprintPure, Category = "SpawningPluginLocationFunctions",
|
||||||
|
meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true"))
|
||||||
|
static FVector GetPlayerLocation(UObject* WorldContextObject);
|
||||||
|
|
||||||
|
// The player's location with a static offset
|
||||||
|
UFUNCTION(BlueprintPure, Category = "SpawningPluginLocationFunctions",
|
||||||
|
meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true"))
|
||||||
|
static FVector GetPlayerLocationWithOffset(UObject* WorldContextObject, float x, float y, float z);
|
||||||
|
|
||||||
|
// The player's location with a random offset
|
||||||
|
UFUNCTION(BlueprintPure, Category = "SpawningPluginLocationFunctions",
|
||||||
|
meta = (WorldContext = "WorldContextObject", UnsafeDuringActorConstruction = "true"))
|
||||||
|
static FVector GetPlayerLocationWithRandomOffset(UObject* WorldContextObject,
|
||||||
|
float minX, float maxX, float minY,
|
||||||
|
float maxY, float minZ, float maxZ);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static APawn* GetPlayerPawn(UObject* WorldContextObject);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user