Whenever I try to use GetComponentByClass I’m hit with some error like type name not allowed or something like that.Can someone just give me a clear example of using GetComponentByClass with UPrimitiveComponent? And what is supposed to mean----TSubclassOf ComponentClass?
Thanks In Advance!
TSubclassOf
is same as UClass*
it just limits the class section to specific base class relation. So TSubclassOf<UActorComponent>
allows oyu to input only classes related to UActorComponent
You need to input UClass*
and you can get UClass*
of each UObject
class by calling static function StaticClass()
inside that class. So you should do something like this:
GetComponentByClass(UPrimitiveComponent::StaticClass());
Thank you for clarifying it. It helped me to understand it a lot.