UKismetMathLibrary::MinOfFloatArray
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPureUFUNCTION
Description
Finds the minimum float in an array and its index. Returns MinValue=0 and IndexOfMinValue=-1 on an empty array.
Caveats & Gotchas
- • NaN values in the array produce unpredictable results since NaN comparisons always return false — sanitize data before passing arrays sourced from physics or external input.
- • Empty array sentinel is 0.0f (not FLT_MAX) — check IndexOfMinValue != -1 to distinguish a real minimum of zero from the empty-array case.
Signature
static ENGINE_API void MinOfFloatArray(const TArray<float>& FloatArray, int32& IndexOfMinValue, float& MinValue); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| FloatArray | const TArray<float>& | The array to search. | — |
| IndexOfMinValue | int32& | Output: index of the minimum value. -1 if array is empty. | — |
| MinValue | float& | Output: the minimum value found. 0 if array is empty. | — |
Return Type
void Example
Find the shortest distance in a set C++
TArray<float> Distances = { 5.2f, 1.1f, 3.4f };
int32 Index;
float MinDist;
UKismetMathLibrary::MinOfFloatArray(Distances, Index, MinDist);
// MinDist == 1.1f, Index == 1 Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?