Hey everyone,
I’m trying to centralize all my debuff definitions in a single UPrimaryDataAsset
so that both server and clients use the exact same data without having to manually replicate huge structs. Here’s my setup:
- DebuffInfo.h
// DebuffInfo.h
UCLASS()
class AURA_API UDebuffInfo : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
// Jede Instanz bekommt anhand ihres Asset-Namens eine eindeutige ID
virtual FPrimaryAssetId GetPrimaryAssetId() const override
{
return FPrimaryAssetId(FPrimaryAssetType("DebuffInfo"), GetFName());
}
// GameplayTag → Debuff-Parameter
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Debuff", meta=(Categories="Debuff"))
TMap<FGameplayTag, FDebuffDefinition> DebuffDefinitions;
};
- EternalAssetManager.h
// EternalAssetManager.h
UCLASS()
class AURA_API UEternalAssetManager : public UAssetManager
{
GENERATED_BODY()
public:
static UEternalAssetManager& Get();
protected:
virtual void StartInitialLoading() override;
};
// EternalAssetManager.cpp
UEternalAssetManager& UEternalAssetManager::Get()
{
check(GEngine);
return *Cast<UEternalAssetManager>(GEngine->AssetManager);
}
void UEternalAssetManager::StartInitialLoading()
{
Super::StartInitialLoading();
// wichtig für GAS-Target-Data in Multiplayer
UAbilitySystemGlobals::Get().InitGlobalData();
}
- EternalAssetManager.cpp
// EternalAssetManager.cpp
UEternalAssetManager& UEternalAssetManager::Get()
{
check(GEngine);
UEternalAssetManager* EternalAssetManager = Cast<UEternalAssetManager>(GEngine->AssetManager);
return *EternalAssetManager;
}
void UEternalAssetManager::StartInitialLoading()
{
Super::StartInitialLoading();
// this is required to use Target Data! (Important in multiplayer!)
UAbilitySystemGlobals::Get().InitGlobalData();
}
I created a blueprint based on the DebuffInfo.h:
In Project Settings → Asset Manager I have added:
And this is how I want to load it:
static const FPrimaryAssetId DebuffInfoId("DebuffInfo", "DA_DebuffInfo");
UDebuffInfo* DebuffInfo = Cast<UDebuffInfo>(
UEternalAssetManager::Get().GetPrimaryAssetObject(DebuffInfoId)
);
if (!DebuffInfo)
{
UE_LOG(LogEternal, Error, TEXT("%s(): Failed to load DebuffInfo asset"), *FString(__FUNCTION__));
return;
}
I always hit the error-log line (DebuffInfo
is nullptr
), even though the asset definitely exists in that location and I’ve configured the Asset Manager accordingly.
Am I missing something important?
Unfortunately I am new and dont really know how to help myself
Thanks in advance for any help!