Hey guys!
I’m making an RPG game, and I’m using GameplayAbilities plug-in. Everything was excellent until now, so I’ll try to explain my problem in detail.
I want to use custom calculation class for applying damage. I’ve setup GameplayEffect to use custom calculation class derived from UGameplayModMagnitudeCalculation.
I made a blueprint from my custom calculation class and selected relevant attributes to capture. I’m planning to use those values to calculate damage (only using one at the moment, for presentational purposes).
UGameplayModMagnitudeCalculation class has this:
UFUNCTION(BlueprintNativeEvent, Category="Calculation")
float CalculateBaseMagnitude(const FGameplayEffectSpec& Spec) const;
All fine, I can override this in blueprint.
I created BlueprintCallable UFUNCTION
UFUNCTION(BlueprintCallable, Category = "Calculation")
float GetMagnitudePerAttribute(FGameplayEffectAttributeCaptureDefinition captureAttribute) const;
in my class that will get the value that I need to pass that value to CalculateBaseMagnitude in Blueprint. Except I have a problem getting the value. I think that I pinpointed the problem, and it’s casting to my class that holds GameplayAttributes derived from AttributeSet.
This should’ve done it:
return captureAttribute.AttributeToCapture.GetNumericValueChecked(CastChecked<UUrathaTalentSet>(captureAttribute.AttributeToCapture.GetAttributeSetClass()));
I tried different types of casts (const, static, dynamic), and nothing works.
After using CastChecked, I’m getting this error:
Fatal error: [File:\Build++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\Templates\Casts.cpp] [Line: 10] Cast of Class /Script/UrathaTheFirstHunt.UrathaTalentSet to UrathaTalentSet failed
GetAttributeSetClass()->GetFullName returns /Script/UrathaTheFirstHunt.UrathaTalentSet and not UrathaTalentSet.
Is this some kind of problem I’m not aware of?
Thanks in advance!
Extra info:
GetNumericValueChecked asks for *const UAttributeSet **;
UUrathaTalentSet is derived from UAttributeSet;
BUT
GetAttributeSetClass return *UClass **; That’s why I’m casting to my UUrathaTalentSet class.
I tried this as well, and no luck:
return captureAttribute.AttributeToCapture.GetNumericValueChecked(CastChecked<UUrathaTalentSet>(captureAttribute.AttributeToCapture.GetUProperty()->GetOuter()));