RealDocs

UKismetArrayLibrary::Array_Set

function Engine Blueprint Since unknown
#include "Kismet/KismetArrayLibrary.h"
Access: public Specifiers: staticBlueprintCallableCustomThunk

Description

Assigns a value to the array element at the given index, optionally growing the array to fit.

Caveats & Gotchas

  • If bSizeToFit is false and Index is out of range, the assignment silently does nothing rather than crashing — check Array_IsValidIndex first if you need to detect that case.
  • When bSizeToFit grows the array, the newly created intermediate slots are default-constructed, not copies of Item — only the slot at Index receives the given value.
  • Displayed in Blueprint as 'Set Array Elem' with no CompactNodeTitle.

Signature

static void Array_Set(UPARAM(ref) TArray<int32>& TargetArray, int32 Index, const int32& Item, bool bSizeToFit);

Parameters

Name Type Description Default
TargetArray UPARAM(ref) TArray<int32>& The array to write to. Passed by reference and mutated in place.
Index int32 The index to assign the item to.
Item const int32& The value to assign at Index.
bSizeToFit bool If true, the array is grown to accommodate Index when it is out of range.

Return Type

void

Example

Overwrite an element C++
TArray<int32> Values = { 10, 20, 30 };
UKismetArrayLibrary::Array_Set(Values, 1, 99, false);
// Values is now { 10, 99, 30 }

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.