tranek / GASDocumentation

My understanding of Unreal Engine 5's GameplayAbilitySystem plugin with a simple multiplayer sample project.
MIT License
4.41k stars 809 forks source link

Suggestion to add explanation on how to setup "InitAttributeSetDefaults()" #127

Open Ayliroe opened 9 months ago

Ayliroe commented 9 months ago

Hello!

While trying to setup the GAS on a project, I could not for the life of me understand how to setup IGameplayAbilitiesModule::Get().GetAbilitySystemGlobals()->GetAttributeSetInitter()->InitAttributeSetDefaults(...).

Calling GetAttributeSetInitter() always crashed, and IsAbilitySystemGlobalsInitialized() always returned false. I added #include "AbilitySystemGlobals.h", setup a a custom Asset Manager in Project Settings that calls UAbilitySystemGlobals::Get().InitGlobalData(); inside StartInitialLoading() override { ...}, tried the function in various places (a class derived from UAttributeSet, a class derived from ACharacter that implements IAbilitySystemInterface, other custom classes) to no avail.

The fix for me was tipped by a comment in that repo: https://github.com/DaedalicEntertainment/ue4-orders-abilities/blob/develop/Source/OrdersAbilities/Private/AbilitySystem/RTSAbilitySystemComponent.cpp In DefaultGame.ini, add a line such as this:

[/Script/GameplayAbilities.AbilitySystemGlobals]
GlobalAttributeSetDefaultsTableNames=/Game/Blueprints/Tables/CT_GlobalAttributes.CT_GlobalAttributes

Where CT_GlobalAttributes is an imported curve table.

Since it took me a dozen hours to figure this out due to how obscure the setup of GAS can be, I think it is worth mentioning in your GASDocumention (which otherwise has been a great help). Cheers!