Lag compensation happens server-side during
Simulate and essentially rewinds lag compensated entities to the position they were in when the client being simulated sent their input commands. This means that traces will hit entities that the client would expect to be hit from their point-of-view.
If you want to enable it for any entities, such as a pawn, you can simply set the
LagCompensation property to true on that entity. This is usually does in the entity's
Simulate you can call
UseLagCompensation() on any trace to enable lag compensation for that trace and any subsequent traces until the end of the simulation.
The following code could be used within a weapon's
PrimaryAttack method. This is because
PrimaryAttack is called within
Simulate and so this trace would be lag compensated.
Note: all subsequent traces will also be affected by lag compensation until the end of the simulation.