I know it says not to change the DT... What happens if you do? What if, for example, I want things to run in slow motion for a short while, then resume normal speed? The simplest way I can think of to do that would be to alter the DT to be smaller for that time while it's running slower. What issues might this cause?
Changing DT
JavaWhen we tell you to not change the dt, I think we're trying to avoid having people just giving the actual time difference from the last step, which causes problems if framerate drops (bigger timestep usually = more computation, which takes longer, which lowers framerate, which makes the time step bigger, etc). So what you're doing, from what I understand, is perfectly fine, and will actually give you better physics simulation as well 😀
That's good to hear. Now I have some more questions about normal ranges for DT and iterations:
I have the standard DT set at 1/20, and the step at 10. The slow DT depends on the speed of the thing being watched. The faster it is, the slower the DT. Essentially, the slow DT is (1/20)/(speed of object). This seems to achieve a good slow down proportional to what I want.
Is 10 a good iteration count to use? I'm just looking for ballpark. Way too high, way too low, or approximately correct?
The other question relates to accuracy with these speeds. When two circles collide, I'm trying to predict what direction they will go. The mathematically correct solution seems to be off by about 0.5x the angle of incidence. That is, if the circles hit right on, I can easily predict that the angle the circles will go will be in the same direction they were traveling before. But as the angle increases, so does the error, and I end up needing to multiply the calculated angle by about 1.5 to get the angle the circles actually goes in. Sometimes it's right on, sometimes it's too little, some times it's too much.
Is there a better way to calculate what angle the projected linear velocity of the circles after collision? I'm not worrying about what else might interact with the circles. Just forgetting everything else in the world, based on two circles, one stationery and one moving, what will be the linear velocity of the stationery circle after contact?
I have the standard DT set at 1/20, and the step at 10. The slow DT depends on the speed of the thing being watched. The faster it is, the slower the DT. Essentially, the slow DT is (1/20)/(speed of object). This seems to achieve a good slow down proportional to what I want.
Is 10 a good iteration count to use? I'm just looking for ballpark. Way too high, way too low, or approximately correct?
The other question relates to accuracy with these speeds. When two circles collide, I'm trying to predict what direction they will go. The mathematically correct solution seems to be off by about 0.5x the angle of incidence. That is, if the circles hit right on, I can easily predict that the angle the circles will go will be in the same direction they were traveling before. But as the angle increases, so does the error, and I end up needing to multiply the calculated angle by about 1.5 to get the angle the circles actually goes in. Sometimes it's right on, sometimes it's too little, some times it's too much.
Is there a better way to calculate what angle the projected linear velocity of the circles after collision? I'm not worrying about what else might interact with the circles. Just forgetting everything else in the world, based on two circles, one stationery and one moving, what will be the linear velocity of the stationery circle after contact?
try having no friction, you might get a better simulation.
10 is fine, basically it's the number of times the engine will try to move objects out from the inside of one another.
dt means "difference of time", so a 1/20 (.05) means .05 seconds have passed. So an object moving at 30 units/second will have moved .05*30 units.
10 is fine, basically it's the number of times the engine will try to move objects out from the inside of one another.
dt means "difference of time", so a 1/20 (.05) means .05 seconds have passed. So an object moving at 30 units/second will have moved .05*30 units.
Original thread: https://box2d.org/forum/viewtopic.php?t=5421