RealDocs

UKismetSystemLibrary::Conv_ObjectToClass

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

Description

Casts an object reference to a UClass, but only succeeds if the object being cast is itself a class (i.e. a UClass instance, not a regular UObject instance). Appears as the "Cast To Class" Blueprint node.

Caveats & Gotchas

  • This only works when Object actually is a UClass — casting a normal actor or component instance to UClass here returns nullptr, it does not return that instance's class.
  • Easy to confuse with GetClass()/Object->GetClass(), which retrieves an object's class; this node instead treats the object reference itself as a class pointer to validate.

Signature

static UClass* Conv_ObjectToClass(UObject* Object, TSubclassOf<UObject> Class)

Parameters

Name Type Description Default
Object UObject* The object to cast. Must itself be a UClass instance.
Class TSubclassOf<UObject> The class type to cast to; drives the node's output pin type via DeterminesOutputType.

Return Type

UClass*

Example

Cast a class reference obtained as UObject* C++
UObject* SomeObjectThatIsAClass = MyClassReference;
UClass* ResultClass = UKismetSystemLibrary::Conv_ObjectToClass(SomeObjectThatIsAClass, UActorComponent::StaticClass());

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.