UKismetMathLibrary::SelectObject
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns A if bSelectA is true, otherwise returns B. Conditionally selects one of two UObject references without adding a branch node to the Blueprint graph.
Caveats & Gotchas
- • Either or both inputs can be null; the function does no validity check and will happily return a null pointer — always IsValid()-check the result before use.
- • The return type is UObject*; if the actual object types differ, Blueprint will attempt an implicit cast which will fail silently at runtime if the types are incompatible.
Signature
static UE_INL_API UObject* SelectObject(UObject* A, UObject* B, bool bSelectA) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | UObject* | Returned when bSelectA is true. | — |
| B | UObject* | Returned when bSelectA is false. | — |
| bSelectA | bool | Selector: true returns A, false returns B. | — |
Return Type
UObject* Example
Select active weapon C++
UObject* Weapon = UKismetMathLibrary::SelectObject(PrimaryWeapon, SecondaryWeapon, bUsePrimary);
if (IsValid(Weapon)) { Cast<AWeapon>(Weapon)->Fire(); } Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?