"Redefinition of formal parameter" build error when trying to output from function.

Along with taking in some inputs, I’m trying to output two vectors, A_Out and B_Out out of this function.
If i understand, I should be able to do this like so:

Then at the end of some calculations I end up with my 2 vectors like so:

image

image

However when I try to build I get an error that I’ve tried to change the “formal parameters” A_Out and B_Out. But how can I make outputs without doing that?

What am I doing wrong?

What exactly are you trying to do? Can you include an image of your CalculateAngles function, as well as how you call it?

The error means you’re redifining your out parameters, in this case. I’m suspecting that you don’t fully understand what passing by reference means, and what an out paramter is. To be fair this is a confusing topic.

Out paramters are not return values, you have to declare them beforehand and use them with the function call.
A_Out and B_Out are being passed by reference. This means that whatever modification you do to them in your function will modify the property that was used as an argument.

This comment explains this very well:

Dutii explained it well. If you want a simple solution, just remove “FVector” in front of A_Out and B_Out.

Redefinition of formal parameters means that you’re declaring a variable that already exists. I.e.

float SomeNumber = 3;
float SomeNumber = 5;

In your case, the variables A_Out and B_Out are created when the function is called (given that they’re declared as parameters in the function declaration), and, in addition to that, you’re creating them at the end of the function.

Thanks! I’ve now got other (much worse, can’t even open the project now) issues but that solved that problem.

Thanks for the responses

e: for the sake of people who google this problem:
it seems to have been solved by getting rid of the type declaration in the body of the code.
So i changed my calculation to just A_Out =(newAN + newAT); etc

If you link your crash dump from when trying to open the project, hopefully we can find a way to fix it.