UKismetMathLibrary::SelectClass
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns A if bSelectA is true, otherwise returns B. Picks between two class references, useful for dynamic spawning logic that varies the actor class based on a condition.
Caveats & Gotchas
- • No type-safety checking is performed — ensure both classes are compatible with whatever system consumes the result (e.g., the SpawnActor node's class pin expects a common base class).
- • Either input may be null; passing null to SpawnActor will assert or silently fail, so validate the result with IsValid before spawning.
Signature
static UE_INL_API UClass* SelectClass(UClass* A, UClass* B, bool bSelectA) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | UClass* | Returned when bSelectA is true. | — |
| B | UClass* | Returned when bSelectA is false. | — |
| bSelectA | bool | Selector: true returns A, false returns B. | — |
Return Type
UClass* Example
Choose enemy class by difficulty C++
UClass* EnemyClass = UKismetMathLibrary::SelectClass(HardEnemyClass, EasyEnemyClass, bHardMode);
World->SpawnActor(EnemyClass, SpawnTransform); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?