Unneccessary warnings "No value will be returned by reference"

UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category=“Battle”)
void OnAfterDeath(UPARAM(ref) FUnit& DeadUnit, int32 DeadUnitID, UPARAM(ref) FUnit& Killer, int32 Line, int32 Faction);

I have the references marked as being inputs and when I call it inside blueprints, then they show up on the input side.

A blueprint that overrides this function however gives warnings for both DeadUnit and Killer, “No value will be returned by reference”

A BlueprintNativeEvent with identical inputs that returns a boolean does not throw similar warnings.

Hello Cerapa-

I’m not sure I understand what your question is. Does the overridden function have the references showing on the input or output side of the node? Can you elaborate on what exactly you’re reporting and what you need help with?

Cheers

The overridden function correctly shows the references as being on the input side of the node. I still get the warning of “No value will be returned by reference”, as if the nodes were on the output side. Or am I misunderstanding the warning? It’s a void function without any outputs, so it makes sense that it doesn’t return any values.

Mostly my question how do I get rid of the warning? Or is there some sort of problem with the way I have this set up?

I tried copying the function declaration you posted into a class along with a definition for it however FUnit was unrecoginzed. When I switched it for a known type (AActor) the compiler told me it was missing an asterisk. I don’t want to change the function too much in case it prevents me from seeing the same issue you are. If FUnit is unique to your project can you provide the code for it or explain how to setup a shell for testing purposes?

FUnit is an UStruct (as indicated by the F) declared in C++, so any struct should suffice as a replacement.

USTRUCT(BlueprintType)
struct FUnit {
	GENERATED_USTRUCT_BODY()

	UPROPERTY(BlueprintReadWrite)
	int32 Value;
}

This ought to be a suitable replacement.

Did some testing though. Seems this warning pops up with any reference.

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category="Battle")
	void NewTest(UPARAM(ref) int32& test);

Exhibits the same problem. So it seems to be a problem with references in general.

The BlueprintImplementableEvent specifier is what is leading to the error. Since blueprint events have no input your reference variable is appearing on the right side of the node where the output typically appears. If you remove the BlueprintImplementableEvent specifier, the blueprint node will show as a blue function node rather than a red event node but the warning message will no longer be displayed.

Cheers

This does not in any concievable way fix my problem. I use the BlueprintImplementableEvent specifier because I want to overload the event inside of blueprints. Not using the specifier is not an option and the suggestion that it would be a reasonable way to get rid of the warning is…I don’t even know how to respond to that.

My reference variable is most definitely not appearing on the right side of the node as an output. They are all on the correct side, as inputs on the event body, and as inputs to the event when called out inside blueprints. The only thing wrong is the warning.

EDIT: Seemingly setting the values of the input reference does not change the values inside the thing being referenced. So it’s actually making a copy at some point?

I did not mean to imply that the variable is being as an output. What I meant was that, in blueprints, pins that appear on the left side of a node are typically thought of/treated as inputs and pins on the right side of the node are thought of as outputs by the blueprint. Since event nodes are the beginning of an execution chain (like BeginPlay) they do not have any input being passed to them. Even though your parameters are being passed as inputs, because it is an event node they appear on the right hand side. The same behavior can be observed if you create a custom event node and give it an input that is pass-by-reference. In this instance, the warning is simply saying that because the reference pin is on the right (where outputs usually are) it will not return a value. Since you already understand what is happening here, it would be safe to ignore the warning message. Another possible solution would be to add another “dummy” function as a BIE. This dummy function can have any functionality you plan to override in the original and then call the function node for OnAfterDeath.

So the warning is unneccessary? I don’t understand its purpose, since it’s clear from the input and output pins what things are inputs and what are outputs. But I didn’t realize that events created through blueprints give the same warning.

Thanks for the help.