tranek / GASDocumentation

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

Clamping value on PreAttributeChanged not working on client #114

Open yolohz opened 1 year ago

yolohz commented 1 year ago

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