RealDocs

UGameplayStatics::GetObjectClass

function Engine Blueprint Since 4.0
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Returns the UClass of the passed-in object. The result is always valid as long as Object is not null, making it safe to use without a null check on the return value.

Caveats & Gotchas

  • Will crash if Object is null — despite the guarantee that the return is always valid when Object is non-null, there is no internal null guard on the input. Always check Object before calling.
  • Returns the exact runtime class, not any Blueprint-generated subclass parent. If you need to check whether an object is of a specific type, prefer Cast<> or ObjectIsA rather than comparing UClass pointers directly.

Signature

static ENGINE_API class UClass *GetObjectClass(const UObject *Object);

Parameters

Name Type Description Default
Object const UObject* The object whose class to retrieve. Must not be null.

Return Type

UClass*

Example

Log the runtime class of an actor C++
if (SomeActor)
{
    UClass* ActorClass = UGameplayStatics::GetObjectClass(SomeActor);
    UE_LOG(LogGame, Log, TEXT("Actor class: %s"), *ActorClass->GetName());
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.