Hi all, Im trying to create a map that stores the multiplier values for certain DamageTypes in my Health types. What Im currently stuck on is that this definition of the array in combination with the attempt to read from it, results in a compiler error.
Has anyone encountered a similiar issue or knows whats wrong with my code?
Definition:
UPROPERTY(EditAnywhere, BlueprintReadOnly)
TMap<TSubclassOf<class UDamageType>, float> HealthTypeMultiplierMap;
Call:
void UCurrentHealthComponent::takeDamage(float* DamageAmount,
FDamageEvent const & DamageEvent,
class AController * EventInstigator)
{
float* damageMultiplier = this->HealthType->HealthTypeMultiplierMap.Find(DamageEvent.DamageTypeClass);
float damageMultiplierForType = (damageMultiplier == nullptr) ? 0 : *damageMultiplier;
[...]
}
Compiler Error:
0>SubclassOf.h(99): Error C2027 : use of undefined type 'UDamageType'
0>GameplayStatics.generated.h(44): Reference C2027 : see declaration of 'UDamageType'
0>SubclassOf.h(99): Reference C2027 : the template instantiation context (the oldest one first) is
0>EngineTypes.h(3197): Reference C2027 : see reference to class template instantiation 'TSubclassOf<UDamageType>' being compiled
0>SubclassOf.h(97): Reference C2027 : while compiling class template member function 'UClass *TSubclassOf<UDamageType>::operator *(void) const'
0>SubclassOf.h(121): Reference C2027 : see the first reference to 'TSubclassOf<UDamageType>::operator *' in 'TSubclassOf<UDamageType>::operator UClass *'
0>Map.h(89): Reference C2027 : see the first reference to 'TSubclassOf<UDamageType>::operator UClass *' in 'TDefaultMapKeyFuncs<KeyType,ValueType,false>::Matches'
with
[
KeyType=TSubclassOf<UDamageType>,
ValueType=float
]
0>Set.h(864): Reference C2027 : see the first reference to 'TDefaultMapKeyFuncs<KeyType,ValueType,false>::Matches' in 'TSet<TTuple<KeyType,ValueType>,KeyFuncs,SetAllocator>::FindId'
with
[
KeyType=TSubclassOf<UDamageType>,
ValueType=float
]
0>Set.h(907): Reference C2027 : see the first reference to 'TSet<TTuple<KeyType,ValueType>,KeyFuncs,SetAllocator>::FindId' in 'TSet<TTuple<KeyType,ValueType>,KeyFuncs,SetAllocator>::Find'
with
[
KeyType=TSubclassOf<UDamageType>,
ValueType=float,
KeyFuncs=TDefaultMapHashableKeyFuncs<TSubclassOf<UDamageType>,float,false>,
SetAllocator=FDefaultSetAllocator
]
0>Map.h(527): Reference C2027 : see the first reference to 'TSet<TTuple<KeyType,ValueType>,KeyFuncs,SetAllocator>::Find' in 'TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>::Find'
with
[
KeyType=TSubclassOf<UDamageType>,
ValueType=float,
KeyFuncs=TDefaultMapHashableKeyFuncs<TSubclassOf<UDamageType>,float,false>,
SetAllocator=FDefaultSetAllocator
]
and
[
KeyType=TSubclassOf<UDamageType>,
ValueType=float,
SetAllocator=FDefaultSetAllocator,
KeyFuncs=TDefaultMapHashableKeyFuncs<TSubclassOf<UDamageType>,float,false>
]
0>CurrentHealthComponent.cpp(97): Reference C2027 : see the first reference to 'TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>::Find' in 'UCurrentHealthComponent::takeDamage'
with
[
KeyType=TSubclassOf<UDamageType>,
ValueType=float,
SetAllocator=FDefaultSetAllocator,
KeyFuncs=TDefaultMapHashableKeyFuncs<TSubclassOf<UDamageType>,float,false>
]
0>SubclassOf.h(99): Error C2672 : 'StaticClass': no matching overloaded function found
0>ReflectedTypeAccessors.h(13): Reference C2672 : could be 'UClass *StaticClass(void)'
0>SubclassOf.h(99): Reference C2672 : 'UClass *StaticClass(void)': could not deduce template argument for 'ClassType'
[3/7] Compile Module.CosmoVibesUE5.gen.cpp
[4/7] Compile Module.CosmoVibesUE5.cpp
0>Microsoft.MakeFile.Targets(44,5): Error MSB3073 : The command ""C:\Program Files\Epic Games\UE_5.0\Engine\Build\BatchFiles\Build.bat" CosmoVibesUE5Editor Win64 Development -Project="V:\Projects\UE5\cosmo-vibes\CosmoVibesUE5.uproject" -WaitMutex -FromMsBuild" exited with code 6.