Skip to content

Commit

Permalink
Improve Ping Compensation For ShockProj
Browse files Browse the repository at this point in the history
  • Loading branch information
Deaod committed Apr 13, 2024
1 parent feb8bbe commit 1284ca7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Classes/ST_ShockProj.uc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var ST_Mutator STM;
var float Health;

var PlayerPawn InstigatingPlayer;
var vector ExtrapolationDelta;

simulated function PostBeginPlay() {
if (ROLE == ROLE_Authority) {
Expand All @@ -23,20 +24,25 @@ simulated function PostNetBeginPlay() {
super.PostNetBeginPlay();

In = PlayerPawn(Instigator);
if (In == none || In.Player == none || In.Player.IsA('Viewport') == false)
return;

InstigatingPlayer = In;
if (In != none && Viewport(In.Player) != none)
InstigatingPlayer = In;
}

simulated event Tick(float Delta) {
local vector NewXPolDelta;
super.Tick(Delta);

if (InstigatingPlayer == none)
return;

// Catch up to server
if (OldLocation == Location)
MoveSmooth(Velocity * (0.001 * InstigatingPlayer.PlayerReplicationInfo.Ping));
MoveSmooth(Velocity * (0.0005 * InstigatingPlayer.PlayerReplicationInfo.Ping));

// Extrapolate locally to compensate for ping
NewXPolDelta = (Velocity * (0.0005 * InstigatingPlayer.PlayerReplicationInfo.Ping));
MoveSmooth(NewXPolDelta - ExtrapolationDelta);
ExtrapolationDelta = NewXPolDelta;
}

function SuperExplosion() {
Expand Down

0 comments on commit 1284ca7

Please sign in to comment.