How to create BlueprintNativeEvent with array as input

Hi, i’m trying to create a blueprint native event with array of vector as input, everything is fine when Function only has BlueprintCallable property,
but after adding UFUCTION(BlueprintNativeEvent, Blueprintcallable, category = “Temp”)
cant compile the code.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "EnemyCharacter.generated.h"

UCLASS()
class SINCEREMEN_API AEnemyCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	AEnemyCharacter();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;


	virtual void OnConstruction(const FTransform& Transform) override;

UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, category = "Enemy")
	void TestFucntion(TArray<FVector> InputValues);

and this is error list:

error C2511: 'void AEnemyCharacter::TestFucntion(const TArray<FVector,FDefaultAllocator> &)': overloaded member function not found in 'AEnemyCharacter'
note: see declaration of 'AEnemyCharacter'
error C2352: 'UObject::FindFunctionChecked': illegal call of non-static member function
note: see declaration of 'UObject::FindFunctionChecked'

In your description you mention using “blueprint native event”, but in your code sample you are using “blueprint implementable event”. Which one are you wanting to use?

It looks like you need to change your function signature to this:

void TestFucntion(const TArray<FVector> & InputValues);
1 Like

Hello ,

In order to use the BlueprintNativeEvent specifier, your function should have the “_Implementation” suffix as in its definition. For example:

#Header file#

UFUNCTION(BlueprintNativeEvent, Category = "My Native Events")
void NativeFuncCall(TArray<FVector>& Values);

#Source file#

void AMyClass::NativeFuncCall_Implementation(TArray<FVector>& Values);

Hope this helps.

Thanks,

Hello Thanks for reply, i added “_Implementation” in the definition, but adding & to (TArray& Values) doesn’t make the array an output for function?

Thank you soo much Steve it fixed the problem, adding const + & make the value as input i didn’t know it

1 Like

use ‘const TArray& Values’ instead.

1 Like