How to obtain super class reference from base class pointer

If I have a pointer to some base class like AActor

AActor * SomeActor = MyGamePawn;

SomeActor->StaticClass() returns AActor class reference instead of MyGamePawn because StaticClass is actually a static method.

There seems to be no way to retreive the actual class of the object.

I even tried adding to ObjectBase.h under DECLARE_CLASS but that resulted in a linker error saying unable to fine GetPrivateStaticClass

/** Returns a UClass object representing the super class of the object at run time even if you have a pointer to a base class */ \
virtual UClass * DynamicClass() \
{ \
	return StaticClass(); \
} \

It sounds like GetClass is what you need.

SomeActor->GetClass();

IsA can also be used if you just want to check the instance is a particular type.

if(SomeActor->IsA(AMyGamePawn::StaticClass())
{
    // ...
}

Ah yes! That’s what I need.

I was reading this doc Gameplay Classes | Unreal Engine Documentation

and saw only mention of the StaticClass method.