Finding out how to create BlueprintNativeEvent with Parameters

I was writing this post as I was debugging it and found the solution, but I thought it would be worth putting my process out there for anyone needing a solution.

I’m trying to create a function that is implementable in C++ and Blueprints with Parameters, so I used BlueprintNativeEvent to do this, but for some reason, when I tried to build the code, it would not compile, saying that the function could not be found in the generated.cpp file.

UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
void OnUse(UFighterComponent* User, TArray<AActor*> Target);

I tried to work backwards and saw that trying this with no parameters worked.

UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
void OnUseNoArgs(); 
virtual void OnUseNoArgs_Implementation(); //Works with C++ Implementation

I also looked at this:

and found that they were only using BlueprintImplementableEvent with parameters. So I tried, and that still works fine too.

UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void OnUseOneArg(UFighterComponent* User); //Works, No C++ Implementation allowed.

UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void OnUseMultiArg(UFighterComponent* User, const TArray<AActor*>& Target); //Works, No C++ Implementation allowed.

However, I had to change the Array to const reference. So I checked the error and the generated code appeared to be asking for the same thing.

I checked the error it was throwing up,
error C2511: ‘void USkillBase::OnUse(UFighterComponent *,const TArray<AActor *,TSizedDefaultAllocator<32>> &)’: overloaded member function not found in ‘USkillBase’

So I did this

UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
void OnUse(UFighterComponent* User, const TArray<AActor*>& Target);

Now I get “Failed to link patch (0.000s) (Exit code: 0x460)”
Reading closely, I realize that I need to put an implementation, so I make a virtual version of the function to be overridden by other C++ classes, and the code is this now.

UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
void OnUse(UFighterComponent* User, const TArray<AActor*>& Target);
virtual void OnUse_Implementation(UFighterComponent* User, const TArray<AActor*>& Target);


void USkillBase::OnUse_Implementation(UFighterComponent* User, const TArray<AActor*>& Target)

and… it works!
Even the override version works.

void USkillAttack::OnUse_Implementation(UFighterComponent* User, const TArray<AActor*>& Target)
	UE_LOG(LogTemp, Warning, TEXT("C++ Skill"));

Good night.