Shooter Game sample question

I having been playing around with the engine and creating a sample multiplayer game. I wanted to make a projectile, and i knew the shooter game sample has one. I was digging around in there, and i came across this function:


void AShooterWeapon_Projectile::FireWeapon()
{
	FVector ShootDir = GetAdjustedAim();
	FVector Origin = GetMuzzleLocation();

	// trace from camera to check what's under crosshair
	const float ProjectileAdjustRange = 10000.0f;
	const FVector StartTrace = GetCameraDamageStartLocation(ShootDir);
	const FVector EndTrace = StartTrace + ShootDir * ProjectileAdjustRange;
	FHitResult Impact = WeaponTrace(StartTrace, EndTrace);
	
	// and adjust directions to hit that actor
	if (Impact.bBlockingHit)
	{
		const FVector AdjustedDir = (Impact.ImpactPoint - Origin).GetSafeNormal();
		bool bWeaponPenetration = false;

		const float DirectionDot = FVector::DotProduct(AdjustedDir, ShootDir);
		if (DirectionDot < 0.0f)
		{
			// shooting backwards = weapon is penetrating
			bWeaponPenetration = true;
		}
		else if (DirectionDot < 0.5f)
		{
			// check for weapon penetration if angle difference is big enough
			// raycast along weapon mesh to check if there's blocking hit

			FVector MuzzleStartTrace = Origin - GetMuzzleDirection() * 150.0f;
			FVector MuzzleEndTrace = Origin;
			FHitResult MuzzleImpact = WeaponTrace(MuzzleStartTrace, MuzzleEndTrace);

			if (MuzzleImpact.bBlockingHit)
			{
				bWeaponPenetration = true;
			}
		}

		if (bWeaponPenetration)
		{
			// spawn at crosshair position
			Origin = Impact.ImpactPoint - ShootDir * 10.0f;
		}
		else
		{
			// adjust direction to hit
			ShootDir = AdjustedDir;
		}
	}

	ServerFireProjectile(Origin, ShootDir);
}

My question is this, i am confused as to what the IF statement of
"if (Impact.bBlockingHit){

}"
is doing. There are statements like “shooting backwards = weapon is penetrating” in that block of code, how can a weapon be shooting backwards?
I am not really sure i understand why there is a weapon trace for a projectile either. I get why you would need on for an instant hit weapon, but for something like a launcher i am confused why the trace is needed.
If someone could maybe explain the need for that IF statement and what game play purpose is it solving, and why there is a trace for a projectile weapon I would appreciate it!

I assume it’s to see if the weapon muzzle is physically penetrating/inside of the mesh that the trace hits. If you notice the “Origin” is the muzzle location, but the trace starts from some “CameraDamageStartLocation”. Using the dot product of the adjusted direction, which is the direction from the muzzle to the impact point, they see if the impact point is in the opposite direction of the shooting direction. If there was a penetration they adjust the origin for spawning of the projectile.

Thank you for the response, that makes sense. I didn’t think about the muzzle of the gun penetrating a mesh. I have seen similar techniques for third person games, because of how far off the camera is from the gun muzzle, i didn’t think it would be needed for a FPS. Makes sense though, thanks again!