Unreal Engine 5.0
Unreal Engine 4.27
Unreal Engine 5.0
Unreal Engine 4.27
A Gameplay Location Container is a structure that contains multiple gameplay tags and one weak pointer to an object implementing IGameplayLocationQuerier
. It represents multiple ‘descriptions’ to a location that can dynamically be resolved (on-demand) on the context object it carries.
You would usually resort to using Gameplay Locations when just the idea of a location means more than the actual FVector
coordinate itself.
Whether instances of a class implementing IGameplayLocationQuerier
resolve a certain tag is determined at compile-time. See UGameplayLocationSettings
.
You can resolve all tags of FGameplayLocationContainer
by calling Get()
, which returns a TArray<FVector>
.
Or you can call GetMap()
, which returns a TMap<FGameplayTag, FVector>
.
Refrain from caching the return value beyond its current scope, and always resolve this on-demand instead.
Unless you want serialization, it is not necessary to mark your FGameplayLocationContainer
class member with UPROPERTY
, as FGameplayLocation
uses TWeakObjectPtr
internally, which will always return nullptr
if the object underneath is no longer valid.
Unreal Engine 5.0
Unreal Engine 4.27
// Simple example
TScriptInterface<IGameplayLocationQuerier> Querier = GetQuerierFromSomewhere();
FGameplayTagContainer GameplayTagContainer;
GameplayTagContainer.AddTag(UGameplayTagsManager::Get().RequestGameplayTag("Your.Tag.X"));
GameplayTagContainer.AddTag(UGameplayTagsManager::Get().RequestGameplayTag("Your.Tag.Y"));
GameplayTagContainer.AddTag(UGameplayTagsManager::Get().RequestGameplayTag("Your.Tag.Z"));
// This example assumes Querier resolves all descendants of "Your.Tag". The move is optional.
FGameplayLocationContainer GameplayLocationContainer{Querier, MoveTemp(GameplayTagContainer)};
...
TArray<FVector> Locations = GameplayLocationContainer.Get();
TMap<FGameplayTag, FVector> Map = GameplayLocationContainer.GetMap();