Hi guys,
I’m trying to make a custom version of the Append array BP node that returns the resulted merged array as an output (the original has no outputs). It’s supposed to be very easy, but as a C++ newbie, I keep failing without fully understanding the code. Could somebody please help me out?
The original function seems to be defined in KismetArrayLibrary.h:
UFUNCTION(BlueprintCallable, CustomThunk, meta=(DisplayName = "Append Array", CompactNodeTitle = "APPEND", ArrayParm = "TargetArray,SourceArray", ArrayTypeDependentParams = "SourceArray"), Category="Utilities|Array")
static void Array_Append(const TArray<int32>& TargetArray, const TArray<int32>& SourceArray);
But here’s when the problems begin. First, for some reason, the declaration takes in value type, even if the blueprint accepts all array types. The function also doesn’t seem to have a definition in KismetArrayLibrary.cpp as usual—the .cpp only has some complex convoluted internal GenericArray_Append() function instead (which seems to more relevant but doesn’t seem to be exposed to BP and has different parameters than the BP node). However, it seems to be related to this template in GeneratedCodeHelpers.h:
template<typename T, typename U>
static void Array_Append(const TArray<T>& TargetArray, const TArray<U>& SourceArray)
{
const_cast<TArray<T>*>(&TargetArray)->Append(SourceArray);
}
This is where my limited knowledge of C++ fails me. I don’t know how make a modified copy of the function that takes generic TArray types and returns generic TArray output. Once I define the type sd , the function works, but now it can only operate on integers, not generic arrays:
**TArray<int32>** void Array_Append(const TArray<int32>& TargetArray, const TArray<int32>& SourceArray);
{
const_cast<TArray<int32>*>(&TargetArray)->Append(SourceArray);
return TargetArray;
}
Could somebody who understands what is going on here please help me out? Any feedback at all will be extremely welcome.