[Solved] Attribute from AttributeSet not showing up in GameplayEffect modifer

plato.manchi
Thu, 05 Jan 2023 19:33:09 +0000
C++

EDIT: Never mind I’m blind. There is HideFromModifiers meta tag on the attribute. Can’t delete the post.

Hi,

I’m following lyra example to create attribute set that has Health and MaxHealth. They both used to show up in gameplay effect, but Health suddenly disappeared.

Here is AttributeSet code

DECLARE_MULTICAST_DELEGATE_TwoParams(FMaxHealthUpdated, const FGameplayEffectSpec& /*effect_spec*/, float /*new_health*/);
DECLARE_MULTICAST_DELEGATE_FourParams(FCurrentHealthUpdated, AActor* /*effect_instigator*/, AActor* /*effect_causer*/, const FGameplayEffectSpec& /*effect_spec*/, float /*new_health*/);

UCLASS()
class TP_ABILITYTEMPLATE_API UTP_AbilityTemplateHealthSet : public UTP_AbilityTemplateAttributeSet
{
	GENERATED_BODY()

public:
	UTP_AbilityTemplateHealthSet();

	ATTRIBUTE_ACCESSORS(UTP_AbilityTemplateHealthSet, CurrentHealth);
	ATTRIBUTE_ACCESSORS(UTP_AbilityTemplateHealthSet, MaxHealth);

	mutable FMaxHealthUpdated m_on_max_health_updated;
	mutable FCurrentHealthUpdated m_on_current_health_updated;

protected:
	UFUNCTION()
	void OnRep_CurrentHealth(const FGameplayAttributeData& old_value);

	UFUNCTION()
	void OnRep_MaxHealth(const FGameplayAttributeData& old_value);

	virtual bool PreGameplayEffectExecute(FGameplayEffectModCallbackData& data) override;
	virtual void PostGameplayEffectExecute(const FGameplayEffectModCallbackData& data) override;

	virtual void PreAttributeBaseChange(const FGameplayAttribute& attribute, float& new_value) const override;
	virtual void PreAttributeChange(const FGameplayAttribute& attribute, float& new_value) override;
	virtual void PostAttributeChange(const FGameplayAttribute& attribute, float old_value, float new_value) override;

	void ClampAttribute(const FGameplayAttribute& attribute, float& new_value) const;

private:
	// The current health attribute.  The health will be capped by the max health attribute.  Health is hidden from modifiers so only executions can modify it.
	UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_CurrentHealth, Category = "TP_AbilityTemplate|CurrentHealth", Meta = (HideFromModifiers, AllowPrivateAccess = true))
	FGameplayAttributeData CurrentHealth;

	// The current max health attribute.  Max health is an attribute since gameplay effects can modify it.
	UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_MaxHealth, Category = "TP_AbilityTemplate|Health", Meta = (AllowPrivateAccess = true))
	FGameplayAttributeData MaxHealth;
};

Parent class for the set is just empty class with the macros in it to define attributes.

#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
	GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
	GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
	GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
	GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)

UCLASS()
class TP_ABILITYTEMPLATE_API UTP_AbilityTemplateAttributeSet : public UAttributeSet
{
	GENERATED_BODY()

};

But in screenshot, I can’t see Health, but I can see MaxHealth populated.

Its just same code from Lyra project. Although initially I declared the delegates as dynamic delegates (Health was showing up during this time). Then I realized I can’t call AddDynamic on delegates, so changed the just multicast just like in Lyra. And suddenly Health stopped showing up.

Sometimes stuff like that happens with blueprint variables with me, and changing the name will bring them back. So I changed the name to CurrentHealth hoping it will show up but didn’t. Changed the delegates to dynamic to see if that makes any difference and it doesn’t. Even adding another attribute into this attributeset doesn’t show up. Only MaxHealth shows up.

I tried deleting the gameplay effect asset and closing project then deleting all temporary files and folders and build project from scratch and still can’t get the attribute to show up.

I’m out of ideas and hoping that someone here might have come across this and know solution for this.

Thanks.

3 posts - 2 participants