Skip to Content
SDK Integration
Unreal Engine 5ExamplesExposing Cheats

Expose Test Controls

A Flayer function can expose a test-only shortcut such as teleporting the player to a known location. Use game-specific APIs for inventory changes, unlocks, or progression skips.

This example teleports the local player pawn. It returns whether the request succeeded and writes diagnostics through Unreal logging.

#include "Flayer/FlayerFunctionLibrary.h" #include "Utils/FlayerFunctionUtils.h" #include "MyTestFunctions.generated.h" UCLASS() class UMyTestFunctions : public UFlayerFunctionLibrary { GENERATED_BODY() public: UMyTestFunctions() { REGISTER_FLAYER_FUNCTION_SHORT( TeleportPlayer, "teleport_player", "Moves the local player to a world location" ); } UFUNCTION() bool TeleportPlayer(float X, float Y, float Z) { APawn* Pawn = UFlayerFunctionUtils::GetPlayerPawn(this); if (!IsValid(Pawn)) { UE_LOG(LogTemp, Warning, TEXT("Cannot teleport because no player pawn is available")); return false; } const FVector Target(X, Y, Z); const bool bMoved = Pawn->SetActorLocation(Target); if (!bMoved) { UE_LOG(LogTemp, Warning, TEXT("Teleport request was rejected")); } return bMoved; } };

Use the same pattern to call your game’s cheat manager, inventory system, or progression API. Return a supported value that describes the result, and log diagnostic detail with Unreal’s logging macros.

To keep a function out of agent discovery, set FFlayerFunctionMeta::bExposed to false when registering it. A non-exposed function remains registered and can still be called when its public name is known.

Last updated on