공부/UE

[UE] PreAttributeChange가 아니라 PostGameplayEffectExecute에서 Clamp 해야 하는 이유

sudo 2025. 11. 2. 23:19
반응형


불에 들어가면 HP가 감소해야 하는데 감소하지 않는 것을 볼 수 있다.

이유는 지금 HP에 대한 Clamp 처리를 PreAttributeChange에서 해주고 있기 때문이다

 

왜 PreAttributeChange에서 해주면 문제가 되는걸까

찾아보니 PreAttributeChange는 BaseValue가 바뀐 직후, CurrentValue는 바뀌기 전에 호출된다고 하더라

 

못믿겠어서 엔진 코드를 직접 찾아봤다

진짜로 PreAttributeChange 이전 콜스택에 FActiveGameplayEffectsContainer::SetAttributeBaseValue 함수 내부에서 BaseValue를 먼저 세팅한 후에 PreAttributeChange를 호출해주고 있었다.

 

그럼 왜 CurrentValue를 바꾸기 전에 Clamp하면 문제가 되나?

일반적인 GameplayEffect의 로직과 계산에 사용되는 값은 BaseValue 기준이 아니고 CurrentValue가 기준이다.

https://dev.epicgames.com/documentation/en-us/unreal-engine/gameplay-attributes-and-attribute-sets-for-the-gameplay-ability-system-in-unreal-engine?utm_source=chatgpt.com

반응형