tranek / GASDocumentation

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

CDOing AttributeSet in constructor results in garbage collection #117

Open rubenmoor opened 1 year ago

rubenmoor commented 1 year ago

https://forums.unrealengine.com/t/duplicating-an-actor-with-an-attributeset-fails/452327/2

This is a post describing the problem and the solution.

In my case, I CDOed the attribute set as described in the documentation and once I added a fifth attribute, the attribute set was nullptr after BeginPlay. Moving the initialization to PreInitializeComponents solved it:


void AMyPawn::PreInitializeComponents()
{
    Super::PreInitializeComponents();
    AttrSetAcceleration = NewObject<UAttrSetAcceleration>(this, "AttrSetAcceleration");
}
```cpp