Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clamping value on PreAttributeChanged not working on client #114

Open
yolohz opened this issue May 30, 2023 · 0 comments
Open

Clamping value on PreAttributeChanged not working on client #114

yolohz opened this issue May 30, 2023 · 0 comments

Comments

@yolohz
Copy link

yolohz commented May 30, 2023

void UGDAttributeSetBase::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
{
// This is called whenever attributes change, so for max health/mana we want to scale the current totals to match
Super::PreAttributeChange(Attribute, NewValue);

// If a Max value changes, adjust current to keep Current % of Current to Max
if (Attribute == GetMaxHealthAttribute()) // GetMaxHealthAttribute comes from the Macros defined at the top of the header
{
	AdjustAttributeForMaxChange(Health, MaxHealth, NewValue, GetHealthAttribute());
}
else if (Attribute == GetMaxManaAttribute())
{
	AdjustAttributeForMaxChange(Mana, MaxMana, NewValue, GetManaAttribute());
}
else if (Attribute == GetMaxStaminaAttribute())
{
	AdjustAttributeForMaxChange(Stamina, MaxStamina, NewValue, GetStaminaAttribute());
}
else if (Attribute == GetMoveSpeedAttribute())
{
	// Cannot slow less than 150 units/s and cannot boost more than 1000 units/s
	NewValue = FMath::Clamp<float>(NewValue, 150, 1000);
}

}

i check the value from the OnChangeMoveSpeed, the value on the client can still be more than 1000
eventhough the GameplayEffect Only applied from the server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant