TTT-2 / TTT2

Trouble in Terrorist Town 2 for Garry's Mod (gmod)
https://steamcommunity.com/sharedfiles/filedetails/?id=1357204556
178 stars 74 forks source link

Sprinting is completely unpredicted #1034

Closed wgetJane closed 11 months ago

wgetJane commented 1 year ago

Your version of TTT2 (mandatory)

Video

https://user-images.githubusercontent.com/52103358/233751307-c52bb09a-1692-48af-a12f-696a06459833.mp4

Describe the bug (mandatory)

your screen will be jittery whenever you start and stop sprinting while moving: i think that this shouldn't be the case

this is horrible for hitreg and gets quickly annoying for people that are susceptible to getting motion sick

To reproduce

  1. hold at least one of your movement keys
  2. start or stop sprinting
  3. prediction error will happen

Expected behaviour

when written correctly, any change in movement speed should be smooth at any ping

this isn't "source engine jank" or whatever, this is just the sprinting code being unpredicted: https://wiki.facepunch.com/gmod/Prediction

Histalek commented 1 year ago

Hmm this definitely doesn't look right, but looking at the sprinting code i don't really see where this speed mismatch is coming from ...

Does cl_showerror 2 show something useful?

Histalek commented 1 year ago

Does cl_showerror 2 show something useful?

I tried myself and there are definitely prediction errors if you stop sprinting (regardless if done by letting go off the sprint button or by running out of stamina). This one is 100% reproducible for me.

As for prediction error on starting to sprint, these only happen to me when done in quick succession to stopping to sprint, which makes them kind of indistinguishable from the above.

Side note: I don't know if the existence of the prediction errors necessarily means that there is prediction happening and the movement data is simply different on client and server. If not you may be right that there is no prediction happening at all..

Histalek commented 1 year ago

On a more positive side note the ttt2 included speedrun item which uses our own SPEED system is predicted correctly. The Blue Bull item (doesn't use speed system) is not.

I don't really know if porting the sprinting code to use the SPEED system is a good idea or not, but it would definitely remove another instance where we fiddle with the players movement data. CC @saibotk @TimGoll opinions?

wgetJane commented 1 year ago

As for prediction error on starting to sprint, these only happen to me when done in quick succession to stopping to sprint

it doesn't happen when you hold the sprint key way before you start moving, do it while you're already moving or right as you start to move

set net_fakelag to something like 200 or 100 and it'll be a lot more obvious (in the video above it's set to 150)

Side note: I don't know if the existence of the prediction errors necessarily means that there is prediction happening and the movement data is simply different on client and server. If not you may be right that there is no prediction happening at all..

it's 100% unpredicted, the way ttt2's sprint works is the client sends a net msg to the server and then the server changes the player's speed upon receiving the net msg, so there's this whole delay before you see the speed change on your end

when done properly, you should see the speed change instantly as soon as you press the sprint key

saibotk commented 1 year ago

Gotta take a look at it but sure sounds good. I thought we would already use that 😄