Game Developer and Unreal Engine enthusiast known as Goober-Gaming has taken to Reddit to propose a "simple and elegant solution" for making third-person weapon handling animations look more realistic.
The method in question involves using an additive "tuck" animation in Unreal Engine 5, along with some math and capsule tracing to determine the alpha of the additive, thus allowing the player character to bring their weapon closer to themselves when near walls or enemies, resulting in a more lifelike effect. As part of the solution, the bullets travel from the barrel to the crosshair, and the gun's position is adjusted to point as closely as possible toward the center, enabling the player to maintain some accuracy even when the weapon is tucked in.