I’m having trouble understanding the reasoning for the code practices used in the videos. For example in this particular section we see code like
/// Look for attached Physics Handle
PhysicsHandle = GetOwner()->FindComponentByClass<UPhysicsHandleComponent>();
if (PhysicsHandle)
{
// Physics handle is found
}
else
{
UE_LOG(LogTemp, Error, TEXT("%s missing physics handle component"), *GetOwner()->GetName())
}
When something like
/// Look for attached Physics Handle
PhysicsHandle = GetOwner()->FindComponentByClass<UPhysicsHandleComponent>();
if (!PhysicsHandle)
{
UE_LOG(LogTemp, Error, TEXT("%s missing physics handle component"), *GetOwner()->GetName())
}
Would do the job just as well but much neater. Is there a reason you prefer to write the entire if/else block rather than testing for the pointer to actually be null?