<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Fix Your Timestep!</title>
	<atom:link href="http://gafferongames.com/game-physics/fix-your-timestep/feed/" rel="self" type="application/rss+xml" />
	<link>http://gafferongames.com</link>
	<description>Glenn Fiedler&#039;s Game Development Articles and Tutorials</description>
	<lastBuildDate>Thu, 10 May 2012 09:36:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: batbrat</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-48979</link>
		<dc:creator>batbrat</dc:creator>
		<pubDate>Thu, 10 May 2012 09:36:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-48979</guid>
		<description>Hi Glenn, I&#039;m sorry I haven&#039;t replied to your comment for a year. I somehow missed the comment notification and I haven&#039;t been back on the site or doing physics simulation for a while now. Thank you so much for your reply and your article. I have more questions, but I need to get my head sorted first.

Thanks again!</description>
		<content:encoded><![CDATA[<p>Hi Glenn, I&#8217;m sorry I haven&#8217;t replied to your comment for a year. I somehow missed the comment notification and I haven&#8217;t been back on the site or doing physics simulation for a while now. Thank you so much for your reply and your article. I have more questions, but I need to get my head sorted first.</p>
<p>Thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robinson</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-43024</link>
		<dc:creator>Robinson</dc:creator>
		<pubDate>Fri, 30 Mar 2012 22:22:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-43024</guid>
		<description>Fantastic.  Just what I was looking for.  My frame-rate never looked so level :-).

Thanks.</description>
		<content:encoded><![CDATA[<p>Fantastic.  Just what I was looking for.  My frame-rate never looked so level <img src='http://gafferongames.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Shafiq</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-38694</link>
		<dc:creator>Imran Shafiq</dc:creator>
		<pubDate>Mon, 20 Feb 2012 12:05:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-38694</guid>
		<description>I tried a few things, but still have issues:

1. I have fixed simulation timestep (20 milliseconds) and a simulation step counter on both sides.
2. Every 300 milliseconds the &quot;Active team&quot; is sending positions/velocities for all objects alongwith the currentSimulationStep number e.g. 8. The &quot;Inactive team&quot; receives the state message after lets say 400 milliseconds when he is already at simulation step 12. I apply the received state positions/velocities, set simulation step at receving end to 8 and then re-run simulation steps in a loop to to get back to step 12 (so basically adjusting and catching up).
3. When the active team finally takes its turn within 4 seconds, (lets say at step 16) I dont apply that move right away I schedule it on the local system 20 simulation steps in future (i.e step 36) and send that info right away to the &quot;inactive team&quot;. This way both systems will apply the &quot;move&quot; command at simulation step 36.

Even with all this in place the game still gets out of sync. One reason I believe is that while the inactive team is re-applying state and catching up on simulation steps, it keeps falling behind in wall clock time as compared to the active team.

Then when the active team makes its move done at step 36. The other team becomes active - and its lets say 500 milliseconds behind the previously active team now. So, now it starts doing teh same routine as an active team.. but this time the inactive team is far ahead in simulation steps. Kind of a mess :)

I cant really assign object ownership to the teams. The two teams have 3 players each.. but then there is the ball which belongs to no one.  

i wish a simple 2d physics engine was deterministic and wouldnt use floats :) the issue is that in my game teh playing field is so small that .001 makes a difference since everything is in motiong and players are flying at the ball trying to deflect it into the goal.. so after a while the ball is completely in different positins. I took care of this with the state sync every 300 milliseconds. but now one phone is so far behind the other one - sometimes by over a second.</description>
		<content:encoded><![CDATA[<p>I tried a few things, but still have issues:</p>
<p>1. I have fixed simulation timestep (20 milliseconds) and a simulation step counter on both sides.<br />
2. Every 300 milliseconds the &#8220;Active team&#8221; is sending positions/velocities for all objects alongwith the currentSimulationStep number e.g. 8. The &#8220;Inactive team&#8221; receives the state message after lets say 400 milliseconds when he is already at simulation step 12. I apply the received state positions/velocities, set simulation step at receving end to 8 and then re-run simulation steps in a loop to to get back to step 12 (so basically adjusting and catching up).<br />
3. When the active team finally takes its turn within 4 seconds, (lets say at step 16) I dont apply that move right away I schedule it on the local system 20 simulation steps in future (i.e step 36) and send that info right away to the &#8220;inactive team&#8221;. This way both systems will apply the &#8220;move&#8221; command at simulation step 36.</p>
<p>Even with all this in place the game still gets out of sync. One reason I believe is that while the inactive team is re-applying state and catching up on simulation steps, it keeps falling behind in wall clock time as compared to the active team.</p>
<p>Then when the active team makes its move done at step 36. The other team becomes active &#8211; and its lets say 500 milliseconds behind the previously active team now. So, now it starts doing teh same routine as an active team.. but this time the inactive team is far ahead in simulation steps. Kind of a mess <img src='http://gafferongames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I cant really assign object ownership to the teams. The two teams have 3 players each.. but then there is the ball which belongs to no one.  </p>
<p>i wish a simple 2d physics engine was deterministic and wouldnt use floats <img src='http://gafferongames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  the issue is that in my game teh playing field is so small that .001 makes a difference since everything is in motiong and players are flying at the ball trying to deflect it into the goal.. so after a while the ball is completely in different positins. I took care of this with the state sync every 300 milliseconds. but now one phone is so far behind the other one &#8211; sometimes by over a second.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-37990</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Tue, 14 Feb 2012 05:11:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-37990</guid>
		<description>And yes, your approach of sending state seems good. You can either run the sim on both sides and have each player broadcast the state for the object they control, or attempt to interpolate between the two last samples received from the other machine, and run the simulation only for &quot;real&quot; physics objects. I recommend the first approach, but first try it without any fancy time synchronization. Just apply the most recent state received over the network and do a visual smoothing (eg. reduce linear/angular error over time). You may find this is good enough. cheers</description>
		<content:encoded><![CDATA[<p>And yes, your approach of sending state seems good. You can either run the sim on both sides and have each player broadcast the state for the object they control, or attempt to interpolate between the two last samples received from the other machine, and run the simulation only for &#8220;real&#8221; physics objects. I recommend the first approach, but first try it without any fancy time synchronization. Just apply the most recent state received over the network and do a visual smoothing (eg. reduce linear/angular error over time). You may find this is good enough. cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-37989</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Tue, 14 Feb 2012 05:09:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-37989</guid>
		<description>Obviously if you have continuous collision the need for fixed timestep to avoid tunneling is greatly reduced or eliminated entirely.</description>
		<content:encoded><![CDATA[<p>Obviously if you have continuous collision the need for fixed timestep to avoid tunneling is greatly reduced or eliminated entirely.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Shafiq</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-37981</link>
		<dc:creator>Imran Shafiq</dc:creator>
		<pubDate>Tue, 14 Feb 2012 03:32:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-37981</guid>
		<description>I currently use variable timestep in my WP7 2D game &quot;Air Soccer Tour&quot;, and havent seen any issues besides the fact that if a frame takes a long time (physics+rendering+AI) the next frame naturally shows a jump in positions of objects. So I have reduced the frequency of AI updates (not computing AI every frame - but physics and render happens every frame) and the game stays between 50FPS to 60FPS and the results are satisfactory. 
But maybe thats because I have very less objects in my game for physics simulation. i.e. 10 dynamic objects with continuous physics (TOI stuff) and 10 static objects. and the game coordinates are 6 meter by 10 meter. small world.
I thought Fixed timestep was a bad idea cause since the game will run fast on good hardware and slow on bad hardware. But you discussion on floating type precision, fixed physics timestep and accumulator logic makes sense.
I do have a question on networked physics. In my game there is no authoritative server, its a casual game so not worried about cheating :). I did a very basic implementation where two phones/players have their own physics + rendering happening and the server is only relaying messages like player1 took this action/moved or player 2 moved. Now obviously the issue is that the physics simulation needs to be absolutely synchronized otherwise the two phones show different world state. And with latency of 100 ms to 200 ms over the internet, the physics go off on both ends with different results. So the next thing I did was use teleportation in the sense that when player 1 moves, it not sends its &quot;action&quot; info but also the whole world state. player 2 receives it and all objects teleport to the received positions before the player 1 action is executed. This of course looks completely un-acceptable to the players :) So my next try is to somehow synchronize the simulation time i.e. instead of just sending the player moved message (which happens every 2-4 seconds I might add and its sort of turn based game) I was thinking the player who is active at the moment (meaning he can take his turn) will fire off simulation time messages to the inactive player (who is waiting on the turn) the inactive player will try to slow down the simulation step time to stay in sync with the time.. so when finally the player moved message arrives, the teleportation wont loook to bad.. but now the issue is that the first player will have to double slow his simulation and it wil become a mess soon :) So, any ideas on a non-authoritative server based two player game?</description>
		<content:encoded><![CDATA[<p>I currently use variable timestep in my WP7 2D game &#8220;Air Soccer Tour&#8221;, and havent seen any issues besides the fact that if a frame takes a long time (physics+rendering+AI) the next frame naturally shows a jump in positions of objects. So I have reduced the frequency of AI updates (not computing AI every frame &#8211; but physics and render happens every frame) and the game stays between 50FPS to 60FPS and the results are satisfactory.<br />
But maybe thats because I have very less objects in my game for physics simulation. i.e. 10 dynamic objects with continuous physics (TOI stuff) and 10 static objects. and the game coordinates are 6 meter by 10 meter. small world.<br />
I thought Fixed timestep was a bad idea cause since the game will run fast on good hardware and slow on bad hardware. But you discussion on floating type precision, fixed physics timestep and accumulator logic makes sense.<br />
I do have a question on networked physics. In my game there is no authoritative server, its a casual game so not worried about cheating <img src='http://gafferongames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I did a very basic implementation where two phones/players have their own physics + rendering happening and the server is only relaying messages like player1 took this action/moved or player 2 moved. Now obviously the issue is that the physics simulation needs to be absolutely synchronized otherwise the two phones show different world state. And with latency of 100 ms to 200 ms over the internet, the physics go off on both ends with different results. So the next thing I did was use teleportation in the sense that when player 1 moves, it not sends its &#8220;action&#8221; info but also the whole world state. player 2 receives it and all objects teleport to the received positions before the player 1 action is executed. This of course looks completely un-acceptable to the players <img src='http://gafferongames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  So my next try is to somehow synchronize the simulation time i.e. instead of just sending the player moved message (which happens every 2-4 seconds I might add and its sort of turn based game) I was thinking the player who is active at the moment (meaning he can take his turn) will fire off simulation time messages to the inactive player (who is waiting on the turn) the inactive player will try to slow down the simulation step time to stay in sync with the time.. so when finally the player moved message arrives, the teleportation wont loook to bad.. but now the issue is that the first player will have to double slow his simulation and it wil become a mess soon <img src='http://gafferongames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  So, any ideas on a non-authoritative server based two player game?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ingo</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-34841</link>
		<dc:creator>Ingo</dc:creator>
		<pubDate>Wed, 18 Jan 2012 10:21:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-34841</guid>
		<description>Thanks, Glenn. I can see why simple extrapolation can be more jerky, at least generally.</description>
		<content:encoded><![CDATA[<p>Thanks, Glenn. I can see why simple extrapolation can be more jerky, at least generally.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William C</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-34619</link>
		<dc:creator>William C</dc:creator>
		<pubDate>Mon, 16 Jan 2012 20:22:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-34619</guid>
		<description>Hi,

There&#039;s something I&#039;ve always been curious about interpolating between the two different states. If say sprite animations were based off specific update states, how is that handle when the states are interpolated? For example, a player is at rest at the last state but now moving in the current state. When the player moves in the current frame, an animation is triggered. If alpha = 0.5, what do you do with the animation? If it is played, then the time passed for the animation will be a negative number. If I had to guess, I&#039;d say to start the animation and if the time elapsed for the anim is less than 0, just display the first frame and if the time is positive, then the animation time is the actual program time minus a fixed step time. Can you clarify if this makes any sense? Thanks!</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>There&#8217;s something I&#8217;ve always been curious about interpolating between the two different states. If say sprite animations were based off specific update states, how is that handle when the states are interpolated? For example, a player is at rest at the last state but now moving in the current state. When the player moves in the current frame, an animation is triggered. If alpha = 0.5, what do you do with the animation? If it is played, then the time passed for the animation will be a negative number. If I had to guess, I&#8217;d say to start the animation and if the time elapsed for the anim is less than 0, just display the first frame and if the time is positive, then the animation time is the actual program time minus a fixed step time. Can you clarify if this makes any sense? Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-34537</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Mon, 16 Jan 2012 06:47:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-34537</guid>
		<description>yes it has been used in many shipped games. of course there are inaccuracies with interpolation, but typically if the game runs acceptably at the simulation framerate -- the interpolation errors are too small to notice. if you choose to extrapolate instead these errors are usually more noticeable. cheers</description>
		<content:encoded><![CDATA[<p>yes it has been used in many shipped games. of course there are inaccuracies with interpolation, but typically if the game runs acceptably at the simulation framerate &#8212; the interpolation errors are too small to notice. if you choose to extrapolate instead these errors are usually more noticeable. cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ingo</title>
		<link>http://gafferongames.com/game-physics/fix-your-timestep/#comment-34434</link>
		<dc:creator>Ingo</dc:creator>
		<pubDate>Sun, 15 Jan 2012 14:30:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/fix-your-timestep/#comment-34434</guid>
		<description>Hi Glenn,

great article! I find your interpolation technique interesting. Is this something that is commonly done in games? Somewhere above, you say that it does not create (visual) penetration.  I don&#039;t see why not. Every inexpensive (relative to the actual physics computation) interpolation technique can create state that is physically not valid. If you take your example of a V-shaped bounce, interpolation could create a position that lies somewhere in white space, e.g., between the top corners of the &quot;V&quot;. If there is another small object at that location that won&#039;t actually be hit, you will get visual penetration, don&#039;t you? Or am I missing something?

Cheers</description>
		<content:encoded><![CDATA[<p>Hi Glenn,</p>
<p>great article! I find your interpolation technique interesting. Is this something that is commonly done in games? Somewhere above, you say that it does not create (visual) penetration.  I don&#8217;t see why not. Every inexpensive (relative to the actual physics computation) interpolation technique can create state that is physically not valid. If you take your example of a V-shaped bounce, interpolation could create a position that lies somewhere in white space, e.g., between the top corners of the &#8220;V&#8221;. If there is another small object at that location that won&#8217;t actually be hit, you will get visual penetration, don&#8217;t you? Or am I missing something?</p>
<p>Cheers</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic page generated in 0.233 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-10 19:06:41 -->

