How can i make a node for my blueprint that outputs the array index from what my x is
Example, i have an array inside c++ code then for my blueprint i can specific what index i want from that array. Then it simply just outputs what on the array indiex
Regular GET operates on arrays created and handled by Blueprints.
If you have array in C++ you can create new class derived from UBlueprintFunctionLibrary and there write getter function for an array. For example something like this: MyBlueprintFunctionLibrary.h:
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBlueprintFunctionLibrary.generated.h"
extern int MyArray[];
UCLASS()
class TESTPROJECT_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
static int GetElemFromMyArray(int index);
};
and
MyBlueprintFunctionLibrary.cpp:
#include "MyBlueprintFunctionLibrary.h"
int MyArray[] = { 1, 2, 3, 4 };
int UMyBlueprintFunctionLibrary::GetElemFromMyArray(int index)
{
return MyArray[index];
}
Next in Blueprint you call GetElemFromMyArray function passing to it index you are interested in.
As long as the array is a UPROPERTY, and accessible from blueprints (BlueprintReadOnly/BlueprintReadWrite), the regular get operator can be used.
Alternatively, one could make either a function in a library as @mzaleczny suggested, or a public UFUNCTION(BlueprintCallable) in the owning class itself for retrieving an element given an index from the desired array.