It seems that when entering the menu the local player position suddenly changes. This is what I observe in LocalOnTick() when hitting escape:
[Client] 14953.068359375 Movement: position: x=0.1 y=-69.608307 z=94.150032
[Client] 14953.068359375 Movement: delta: x=0 y=-0.69083405 z=0
[Client] 14957.119140625 Movement: position: x=0.34057793 y=-237.06653 z=306.82147
[Client] 14957.119140625 Movement: delta: x=-0.24057794 y=167.45822 z=-212.67145
[Client] 14957.143554688 Movement: position: x=0.34057793 y=-237.06653 z=306.70731
[Client] 14957.143554688 Movement: delta: x=0 y=0 z=0.11416626
[Client] 14957.159179688 Movement: position: x=0.34057793 y=-237.06653 z=306.16013
[Client] 14957.159179688 Movement: delta: x=0 y=0 z=0.54718018
[Client] 14957.171875 Movement: position: x=0.34057793 y=-237.06653 z=305.35706
[Client] 14957.171875 Movement: delta: x=0 y=0 z=0.80307007
[Client] 14957.188476563 Movement: position: x=0.099975586 y=-69.608337 z=94.150024
[Client] 14957.188476563 Movement: delta: x=0.24060234 y=-167.45819 z=211.20703
The first position and delta are when standing still. Then when hitting escape at 14957.119140625 you see the position suddenly jumps to a completely different position and then quickly returns back at 14957.188476563 (while still in the menu).
The code I’m using to measure this is:
function MovementScript:LocalInit()
self.lastPosition = self:GetEntity():GetPosition()
end
---
-- @tparam number deltaTimeSeconds
function MovementScript:LocalOnTick(deltaTimeSeconds)
local position = self:GetEntity():GetPosition()
local delta = self.lastPosition - position
if (self.lastPosition ~= position) then
Printf("{1} Movement: position: {2}", GetWorld():GetServerTime(), position)
Printf("{1} Movement: delta: {2}", GetWorld():GetServerTime(), delta)
end
self.lastPosition = position
end
This behaviour is only observed on the local client.
This breaks any game that uses the player position in the game logic. For now I’m working around this by ignoring deltas above 60.