How to identify a component by type?

Hi All

I’d like to modify an existing function that cycles through the UPrimitiveComponent’s of an actor using GetComponents(). How would I check which one of those is the UStaticMeshComponent? Many thanks for your time!

You may be able to do a typecast on the components to UStaticMeshComponent and then null check it.

Implicit typecast? So just initialize a variable of UStaticMeshComponent, use = . If its null it aint it. I’ll try that

Ok, do you mean something like this;
UPrimitiveComponent* PrimComp = Components[i];
TSubclassOf* CheckComp = Cast<TSubclassOf > (PrimComp);

Looks like you can do if (PrimComp->IsA(UStaticMeshComponent::StaticClass())) {}

Yeah that should do it.