GAS Default Starting Data Setup

Trying to understand whats needed to get default starting data setup for GAS component attribute set. i followed the tutorial below using the tutorial code as example.

v=YvXvWa6vbAA&t=9814s

I have created attribute class and setup data table with my attribute set inside the character’s GAS component in BP under the attribute test section.

I have created the GAS component inside characters constructor

In characters beginplay i have called GetSet on the GAS component to initialise the pointer to attributes.

And in my characters tick, i have function that periodically logs the value of the attributes and its all showing zero. not matching the values in my data table.

Its just a simple experiment to confirm that attributes are initialised with data from datatable.

my question is, am i , missing any crucial steps here

on another note struggling to post this question
UNreal engine please make the version tag thing more intuitive for making posts struggling to post due to version tag not added and i have no idea what version its asking for i only know of ue4 and ue5
stop putting blockers that require expert knowledge to making posts to ask questions.

thanks

Happy to help, but I’m not going to watch a 3-hour video to guess what your code might look like/is supposed to look like.

It sounds like your problem is that the attribute values are not getting set properly. And it vaguely sounds like you are storing the desired values in a data table, but for some reason the attributes are not getting initialized to those values. Please show us the code that sets the attribute values to the values in the data table, and then maybe we can help troubleshoot what’s wrong with that code.

Thanks for the reply

Below shows details panel for characters GAS component , to the right i have given its default starting data as my table.

My very simple attribute class declaration

// Uses macros from AttributeSet.h
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
	GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
	GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
	GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
	GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)  



class UC_CharAttributeSet : public UAttributeSet
{
	GENERATED_BODY()

friend AC_GasCharacterBase;
	
protected:
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "CharAttribute")
	FGameplayAttributeData Health;
	ATTRIBUTE_ACCESSORS(UC_CharAttributeSet, Health)

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "CharAttribute")
	FGameplayAttributeData WalkSpeed;
	ATTRIBUTE_ACCESSORS(UC_CharAttributeSet, WalkSpeed)

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "CharAttribute")
	FGameplayAttributeData JumpCoef;
	ATTRIBUTE_ACCESSORS(UC_CharAttributeSet, JumpCoef)

};

below is my character cpp code

AC_GasCharacterBase::AC_GasCharacterBase()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	mvo_pGasComp = CreateDefaultSubobject<UAbilitySystemComponent>(TEXT("CharGasComponent"));

}

// Called when the game starts or when spawned
void AC_GasCharacterBase::BeginPlay()
{
	Super::BeginPlay();

	//Initializes the attribute set using a data table.
	verifyf(IsValid(mvo_pGasComp), TEXT("Invalid gas comp"));
	//initlaise attribute pointer, hopefully this should be populated with data from my table 
	mvo_pCharAttrSpec = mvo_pGasComp->GetSet<UC_CharAttributeSet>();

	verifyf(IsValid(mvo_pCharAttrSpec), TEXT("Invalid gas attributes"));
}

// Called every frame
void AC_GasCharacterBase::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	mfo_DisplayAttributes();

}

And below is my data table

Thanks again

I haven’t tried the data table method before, but I don’t see where the error is.

thanks checking it out for for confirmation

found the problem in the bit that prints out the attribute values inside tick, i was using %d as print format, but using %f shows exactly what i have in the table.

I could be wrong , but atleast using %d you should still get the integer of the float without decimal points, but here it just shows zero if the value is a float and format is %d.

Thanks again

Hello, anonymous_user_669611a5. I might know the reason why you encountered the problem.

If you run the demo in the Client, you can check your Attributes Replicated Keyword In UPROPERTY macro.

The reason is that the attributes are only initialized on the server.