If a linetrace does not hit, the hit target vector is (0,0,0) - this makes the weapon rotation correction react weird by rotating towards the center of the world. Sorry having posted a lot of stuff before with a working solution, but too complex. The solution for this is much simpler.
In UCombatComponent::TraceUnderCrosshairs(), add the following check after the linetrace:
GetWorld()->LineTraceSingleByChannel(TraceHitResult, Start, End, ECollisionChannel::ECC_Visibility);
// make sure, that the impact point is not (0,0,0) - set to linetrace end point
if (!TraceHitResult.bBlockingHit) TraceHitResult.ImpactPoint = End;```
And now, I believe to remember, that stuff had been in there, but Stephen did remove some whole codeblock - when I already wondered about possible side effects.
Edit: I found the place where this happened: it is in video "Replicating The Hit Target" at 07:23, where that whole codeblock does get removed.
BTW: it looks like code can be simpler (at least for now, no need for a complete transform, we only need the location)
```c++
// There's no need to get the full transform as done in course, location is sufficient for now
FVector RightHandLocation = EquippedWeapon->GetWeaponMesh()->GetSocketLocation(FName("hand_r"));
// we need to get the opposite direction, so do not simply pass in the Hit Target!
RightHandRotation = UKismetMathLibrary::FindLookAtRotation(RightHandLocation, RightHandLocation + (RightHandLocation - CombatHitTarget));```