BuildingEscape - Unnecessary if else statement for checking for PhysicsHandle

You can just use

PhysHandle = GetOwner()->FindComponentByClass<UPhysicsHandleComponent>();
if (!PhysHandle)
{
	UE_LOG(LogTemp, Error, TEXT("Grabber: No physics handle component on %s"), *GetOwner()->GetName());
}

Rather than checking if there is a handle, doing nothing, and logging an error in an else statement.

Edit:
Okay, in lecture 123 when refactoring they even move it into it’s own function because it’s too verbose.

Edit 2:
This is addressed finally in lecture 127

2 Likes

Privacy & Terms