Accessing Subclasses of a class in C++

Hello All,

I just had a quick question because I’m having a hard time finding documentation that I can really understand on this issue.

I’m trying to get the class of an actor and compare it to one of my custom classes (to determine whether the actor is an instance of my class of interest. The problem here is, the compiler complains about this (what I have below) and I don’t really know the syntax for this or why it will or will not work. Additionally, I would actually like to make my statement check “if ActorClass == (AnySubclassOf)AMNPickup” but I’m having a bit of a hard time figuring out how to do this. I’d really appreciate any help here. Even links to documentation that I may have overlooked would be helpful.

Thanks

void AMNCharacter::CheckForInteractables(){
	TArray<AActor*> ThingsImTouching;
	GetOverlappingActors(ThingsImTouching);
	for (AActor* Thing : ThingsImTouching)
	{
		if (Thing->GetActorClass() == AMNPickup)
		{

		}

	}
}

EDIT: Just a note, VS is telling me that I can’t use AMNPickup because: “type name is not allowed”

Wow… I tried that earlier and it didn’t work… I must have typed something wrong… thanks for pointing this out.

Also IsA() is going to be very helpful in the future. Thanks a bunch.

try AMNPickup::StaticClass().

All UObject derrived classes have a StaticClass() which returns their UClass*. Any UObject can also tell you if it is a subclass of another UObject type: Thing->IsA(AActor::StaticClass()) would == true for example.

My pleasure good luck!