RealDocs

UKismetMathLibrary::SelectFloat

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

Description

Returns A if bPickA is true, otherwise returns B. Use to conditionally choose between two float/double values, such as toggling between walk and sprint speeds based on an input boolean.

Caveats & Gotchas

  • The C++ signature uses `double`, not `float`, reflecting UE5's promotion of Blueprint floats to double precision. UE4 projects migrated to UE5 may see silent implicit conversions if float locals are wired into this node — check for precision narrowing in performance-sensitive simulations.
  • NaN propagation: if either input is NaN, some compilers may propagate the NaN to the output even when that input is not the selected one, depending on optimization level and CPU floating-point mode. Guard NaN inputs explicitly if the source data is untrusted.

Signature

static UE_INL_API double SelectFloat(double A, double B, bool bPickA);

Parameters

Name Type Description Default
A double The float returned when bPickA is true.
B double The float returned when bPickA is false.
bPickA bool Selects A when true, B when false.

Return Type

double

Example

Toggle between walk and sprint speed based on sprint input C++
float DesiredSpeed = UKismetMathLibrary::SelectFloat(SprintSpeed, WalkSpeed, bIsSprinting);
GetCharacterMovement()->MaxWalkSpeed = DesiredSpeed;

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.