I mainly want to confirm if there would have been any side effect to using this instead of the route that was taught after the challenge to log the actor being hit by our Line Trace.
Below is a sample of the code I used when completing the challenge to output the hit actors:
if (Hit.Actor != NULL)
{
UE_LOG(LogTemp, Warning, TEXT("Hitting: %s"), *Hit.Actor->GetName());
}
Admittedly it seems messy, and part of it came to me as I’ve got about a decade experience with SQL so I’m used to the idea of using is not NULL type of scenarios in queries/codes.
What I found however is that it worked! I was able to compile this without any issues and it properly logged the proper objects that I was hitting with the ray trace and from what I could tell the if condition was protecting against any potential NULL pointers.
What I’d like to confirm though is if this is truly an alternative or if I had kept that code in place that it would have caused some sort of issue down the line?
PS Edit: Viewing the next video and completely got reminded that memory pointers when NULL would be nullptr (I’ve done some C++ in the past and just completely forgot about initializing pointers with nullptr) so technically that if statement likely isn’t working, but it still compiled. Because it’d never equal NULL in general then it was probably the same as if I just had the UE_LOG code by itself.
Still interesting that *Hit.Actor seems equivalent to Hit.GetActor() though when using a GetName() afterwards.