RealDocs

UKismetMathLibrary::ClassIsChildOf

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

Description

Returns true if TestClass is the same as ParentClass or is derived from it. Useful for runtime class hierarchy checks without requiring a Cast.

Caveats & Gotchas

  • Returns false if either parameter is None/null — not true — so validate your class references before calling if a null parent should be treated as 'is child of everything'.
  • Checks the full inheritance chain at runtime using UClass::IsChildOf, which walks the parent chain. This is generally fast but avoid calling it in tight per-frame loops on large hierarchies.

Signature

static ENGINE_API bool ClassIsChildOf(TSubclassOf<class UObject> TestClass, TSubclassOf<class UObject> ParentClass)

Parameters

Name Type Description Default
TestClass TSubclassOf<class UObject> The class to test.
ParentClass TSubclassOf<class UObject> The potential parent class.

Return Type

bool

Example

Gate spawning to pawn subclasses only C++
TSubclassOf<UObject> Cls = SomeAsset->LoadedClass;
if (UKismetMathLibrary::ClassIsChildOf(Cls, APawn::StaticClass()))
{
    World->SpawnActor<APawn>(Cls, SpawnTransform);
}

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.