{"id":240,"date":"2007-06-28T05:28:26","date_gmt":"2007-06-28T09:28:26","guid":{"rendered":"http:\/\/www.rakkar.org\/blog\/?p=240"},"modified":"2007-06-28T05:28:26","modified_gmt":"2007-06-28T09:28:26","slug":"trajectory-intercept-interpolation","status":"publish","type":"post","link":"https:\/\/rakkar.org\/blog\/index.php\/2007\/06\/28\/trajectory-intercept-interpolation\/","title":{"rendered":"Trajectory intercept interpolation"},"content":{"rendered":"<p>\t\t\t\tMy &#8220;slippery tail&#8221; interpolation worked well for rotation.  Rotation has no inertia (start and stop immediately).  The magic number to lag behind is half your ping to the server.  This definitely wasn&#8217;t obvious why and it took me an hour of thinking to really see it.<\/p>\n<p>It doesn&#8217;t work for position.  Theoretically it should work, but in practice small errors in timing, ping variances, and high latency all cause failure.  On the front side, when I am finishing a prior interpolation, if my new extrapolated position doesn&#8217;t match exactly, I get a position warp.  This happens easily from ping variance.  On the back side, with very high pings the extrapolated position differences are so large it just ends up looking like a warp.<\/p>\n<p>For position I&#8217;m trying what I call trajectory intercept interpolation.  When the datagram arrives I store the current visual position and physics velocity.  The start interpolation position is where you would normally be (visual position + original velocity * elapsed interp time).  The end interpolation is the intercept when we stop interpolating (real position + real velocity * remaining interp time).<\/p>\n<p>This method doesn&#8217;t jerk (jerk is a change in acceleration) which I do get if I were to not count original velocity. It also gives me an accurate visual position.   Hopefully it will work.<\/p>\n<p>Other problems fixed:<br \/>\nPhysX jitters using fixed timesteps.  Fixed by changing to variable.<br \/>\nStopped using per-datagram timestamps.  Just use half the average ping.  This also removes a potential cheat.<br \/>\nI was previously allowing you to accelerate past your maximum velocity, then clamping the next tick.  This caused inaccuracy.  Now I have to duplicate the physics calculations and determine the force to apply to make you reach your maximum velocity exactly.<br \/>\nPreviously network packets were processed after the tick update, so clearing acceleration didn&#8217;t take until one tick too late, resulting in slightly too high velocity.<\/p>\n<p>These bugs were massively difficult to find.  This has been a very painful day.\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My &#8220;slippery tail&#8221; interpolation worked well for rotation. Rotation has no inertia (start and stop immediately). The magic number to lag behind is half your ping to the server. This definitely wasn&#8217;t obvious why and it took me an hour of thinking to really see it. It doesn&#8217;t work for position. Theoretically it should work, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/240"}],"collection":[{"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=240"}],"version-history":[{"count":0,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/240\/revisions"}],"wp:attachment":[{"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}