OldUnreal / UnrealTournamentPatches

Other
1.03k stars 30 forks source link

Bugged player movement on movers #1621

Closed owythings closed 1 month ago

owythings commented 2 months ago

When moving (running & walking) while standing on a moving mover, client location updates with wrong postions, causing for very inaccurate player locations.

Video example is with only ~17 ms ping.

Tested from 469b through 469e Test 674. Probably a bug related to SavedMove introduced since 469.

Example map: Moving_On_Mover_Bug469.zip

owythings commented 1 month ago

Fixed the bug in our custom PlayerPawn. My solution:

Save mover location in ClientAdjustPosition():

function ClientAdjustPosition
(
    float TimeStamp,
    name newState,
    EPhysics newPhysics,
    float NewLocX,
    float NewLocY,
    float NewLocZ,
    float NewVelX,
    float NewVelY,
    float NewVelZ,
    Actor NewBase
)
{
    // Saving the Mover's location pre adjust
    // Similar to how the Player's location is saved pre adjust (PreAdjustLocation)
    if(Mover(Base) != None)
        PreAdjustMoverLocation = Base.Location;

    Super.ClientAdjustPosition(
        TimeStamp,
        newState,
        newPhysics,
        NewLocX,
        NewLocY,
        NewLocZ,
        NewVelX,
        NewVelY,
        NewVelZ,
        NewBase
    );
}

Use the mover's position to get the real AdjustDistance, inside ClientUpdatePosition():

    AdjustLocationOffset = (Location - PreAdjustLocation); // ORIGINAL LINE
    if(Mover(Base) != None) // ADDED LINE TO TAKE IN ACCOUNT MOVER POSITION DIFFERENCE
        AdjustLocationOffset -= Base.Location - PreAdjustMoverLocation; // ADDED LINE TO TAKE IN ACCOUNT MOVER POSITION DIFFERENCE

We will be testing it thoroughly for any side effects. I'm very confident this is the proper solution.