When I refill mana by 100 points(with gameplay effect) . On my Hud I still see 100, but internally character has more and it keeps 100 until falls below 100 so I can actually see changes.
Where do I clamp values properly? I tried reading Tranek Git Documentaiton but is so confusing as it points to this methods…
I tried 2 methods of clamping my Attributes.
#include "BasicAttributeSet.h"
void UBasicAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
{
if (Attribute == GetHealthAttribute()) {
NewValue = FMath::Clamp<float>(NewValue, 0.f, MaxHealth.GetCurrentValue());
}
if (Attribute == GetManaAttribute()) {
NewValue = FMath::Clamp<float>(NewValue, 0.f, MaxMana.GetCurrentValue());
//NewValue = FMath::Clamp<float>(NewValue, 0.f, 60.f);
}
}
void UBasicAttributeSet::PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue)
{
if (Attribute == GetHealthAttribute()) {
NewValue = FMath::Clamp<float>(NewValue, 0.f, MaxHealth.GetCurrentValue());
}
if (Attribute == GetManaAttribute()) {
NewValue = FMath::Clamp<float>(NewValue, 0.f, MaxMana.GetCurrentValue());
}
}