diff --git a/README.md b/README.md index c166270e..70284ba2 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,8 @@ The best documentation will always be the plugin source code. > 9.2 [`ScriptStructCache` errors](#troubleshooting-scriptstructcache) > 9.3 [Animation Montages are not replicating to clients](#troubleshooting-replicatinganimmontages) > 9.4 [Duplicating Blueprint Actors is setting AttributeSets to nullptr](#troubleshooting-duplicatingblueprintactors) +>       9.4.1 [Not creating `AttributeSet` in the constructor](#troubleshooting-duplicatingblueprintactors-no-constructor) +>       9.4.2 [Making `AttributeSet` `Transient`](#troubleshooting-duplicatingblueprintactors-transient) > 9.5 [unresolved external symbol UEPushModelPrivate::MarkPropertyDirty(int,int)](#troubleshooting-unresolvedexternalsymbolmarkpropertydirty) > 9.6 [Enum names are now represented by path name](#troubleshooting-enumnamesarenowpathnames) > 1. [Common GAS Acronyms](#acronyms) @@ -3126,7 +3128,11 @@ Make sure that you're using the `PlayMontageAndWait` Blueprint node instead of ` ### 9.4 Duplicating Blueprint Actors is setting AttributeSets to nullptr -There is a [bug in Unreal Engine](https://issues.unrealengine.com/issue/UE-81109) that will set `AttributeSet` pointers on your classes to nullptr for Blueprint Actor classes that are duplicated from existing Blueprint Actor classes. There are a few workarounds for this. I've had success not creating bespoke `AttributeSet` pointers on my classes (no pointer in the .h, not calling `CreateDefaultSubobject` in the constructor) and instead just directly adding `AttributeSets` to the `ASC` in `PostInitializeComponents()` (not shown in the Sample Project). The replicated `AttributeSets` will still live in the `ASC's` `SpawnedAttributes` array. It would look something like this: +There is a [bug in Unreal Engine](https://issues.unrealengine.com/issue/UE-81109) that will set `AttributeSet` pointers on your classes to nullptr for Blueprint Actor classes that are duplicated from existing Blueprint Actor classes. There are a few workarounds for this: + + +#### 9.4.1 Not creating `AttributeSet` in the constructor +I've had success not creating bespoke `AttributeSet` pointers on my classes (no pointer in the .h, not calling `CreateDefaultSubobject` in the constructor) and instead just directly adding `AttributeSets` to the `ASC` in `PostInitializeComponents()` (not shown in the Sample Project). The replicated `AttributeSets` will still live in the `ASC's` `SpawnedAttributes` array. It would look something like this: ```c++ void AGDPlayerState::PostInitializeComponents() @@ -3177,6 +3183,18 @@ if (AbilitySystemComponent) As a reminder, the `ASC` only ever expects at most one `AttributeSet` object per `AttributeSet` class. + +#### 9.4.2 Making `AttributeSet` `Transient` +The other workaround for this issue, which seems to work, is to set the `AttributeSet` object to be `Transient`: + +```c++ +UPROPERTY(Transient) +class UGDAttributeSetBase* AttributeSetBase; +``` + +Thanks to that, even when the `AttributeSet` is created in the constructor it won't be serialized and copied when duplicating Blueprint Actor. + + **[⬆ Back to Top](#table-of-contents)**