C++ function switches parameters and outputs in blueprints

As the title says, I have a function written in C++ like so UFUNCTION(BlueprintCallable, Category = Enemy) void ProcessTrace(FHitResult& Impact) but when I try to call it inside Blueprints, the node has reversed the input and output and this is what I get:

32396-function.png

Can someone explain why this is happening?

I can’t really test this myself, but could it be that the keyword ‘const’ prior to FHitResult fixes this issue?

The reason is because my function takes a reference to a FHitResult. I declared another function like this:

void ProcessTrace(FHitResult Impact) (no &) and it appears correctly in blueprints.

You should be able to pass things in by reference without them being forced to out, but it is good that you have it working. I have tested using the ‘const’ keyword and it allows for passing in objects by reference. My c++ is bad, so I can’t really explain this, but hopefully someone else will be able to better explain it.

You’ve specified an out parameter. Change it to (const FHitResult& Impact).

References are treated as output parameters by the engine. Marking it const (constant) prohibits modification, and the engine will treat them as input parameters.