In the lecture, the Hit (FHitResult) is simply returned through the return value. But doesn’t this make a copy of the Hit making it more inefficient? I realise that we can’t return a pointer to try and avoid making a copy as that would mean we are pointing to a local object which will get destroyed when the function ends. However, we could use a reference to the Hit as an out parameter (I have tested and confirmed this) thus making no copy.
Like this:
So is this okay? And yes I know it might be ‘naughty’ but I know exactly what is happening and it seems to be more efficient so yeah…?
EDIT: Also I could have a comment and #define making it clear what’s happening as well but didn’t bother with the example.