![]() ![]() Behaviors already use dtĪll of Construct's behaviors use dt in their internal movement calculations. If you constantly move the object forwards, you could move it forward 60 * dt pixels to move it at 60 pixels per second at its current angle. For example, Sprite's Move forward action takes a number of pixels to move the object forward. Use dt everywhereĪny time you move an object at a steady speed, you need to use dt in that way to achieve framerate independence. This means at both 30 FPS and 60 FPS our object moves to the right 60 pixels every second - the same speed, regardless of framerate. Since dt adds up to 1 every second, 60 * dt adds to up to 60 every second. the object will move to the right at 60 pixels per second at any framerate. Notice that if you add dt to a variable every tick, it adds 1 every second, because the time between all the ticks over a period of 1 second must add up to 1! Here's an example showing just that. In practice, dt varies tick-by-tick, so it is unlikely to be exactly the same value for long periods of time. It is the time, in seconds, since the last tick.įor example, at 100 fps dt will be 0.01 (one hundredth of a second), and at 10 fps dt will be 0.1 (one tenth of a second). Delta means a change in a quantity, so delta-time means the change in time. The key to framerate independence is the dt system expression. The same technique also enables time scaling, which allows for deliberate slow-motion effects and easy pausing. This tutorial describes how you can make your game framerate independent. Games which slow down when the framerate dips can severely affect gameplay, making players get frustrated and quit! Additionally some systems have displays with different refresh rates like 120 Hz, so framerate independence is important to make sure the game doesn't speed up and become impossibly fast on those devices. Making framerate independent games is important to make sure your game is enjoyable and playable for everyone, no matter what kind of computer they have. On the other hand, a framerate dependent game progresses at half the speed on the slow computer, in a sort of slow-motion effect. A framerate independent game progresses at the same speed on both computers (objects appear to move at the same speed). For example, a game might run at 30 FPS (Frames Per Second) on a slow computer, and 60 FPS on a fast one. Framerate independent games are games that run at the same speed, no matter the framerate. ![]()
0 Comments
Leave a Reply. |