Think of pointers as a box that contains a number;
This box is a value, contains something inside:
ACharacter* MyCharacterA // ← there’s a number in there: 14687354
ACharacter* MyCharacterB // ← there’s a number in there: 86587531
The number inside the box is the address of the thing that pointer is pointing to, in this case a ACharacter entity. The address number in the box is where that character lives in the RAM of your computer.
A reference is a label you give the actual ACharacter, or to that box with the address of the ACharacter.
When you access a label, a reference, you are telling C++ compiler to use the object you named that label. The compiler just picks the box and use it…
When you access a box, a pointer, the compiler will pick the box, read the number inside, then it will go all the way to your RAM and finally access the ACharacter living in that address.
You can have several boxes, containing the address of another box, with the address of another box, and so on… Up to the box which finally contains the address of the ACharacter entity.
Your program will visit and open each box until it goes to the one that gives the address of that entity.
But references contain no value. They just give identity to something that actually exist.
Because they hold no value, Unreal Build Tool assume that you want an output pin that is accessing something “named” that label.
You can also give a label to a pointer, not just objects, so:
ACharacter* & _Character; // ← there’s no number, no address, this is not a box.
Above, you have the obligation to tell the compiler what is the object that label is representing.
That is something of type ACharacter* you gave this label while in the body of this function.
The actual ACharacter* is found outside the function. You can’t change the label you gave the box.
const ACharacter* & _Character; // ← same as above!
But here, you promise that you won’t change what is inside the box, once the label is attached to a valid box, a pointer. You also can’t change the label you gave the box, not only that, you cannot change the address number inside the box either.
Unreal Build Tool assume that you want to use this label as an input.
But it is going to scream at you if you never give a box for this label to be slapped onto, while in the body of the function. Because labels have no value… Unreal is going to tell you:
The current value of the '_Character ' pin is invalid: Reference inputs must have an input wired into them.
Let’s say you used MyCharacterA as input, _Character is now its local label…
Now let’s say you’re done with MyCharacterA and want work on MyCharacterB.
_Character = MyCharacterB;
But you get an error because you’ve promised you would not change the number inside MyCharacterA box. For the compiler, _Character is simply another name for MyCharacterA.
UPARAM(ref) tells Unreal that you want a label as input, but you will not promise that you will never change the number address in the actual box or the state of MyCharacterA.