官术网_书友最值得收藏!

About delta

The _process() function includes a parameter called delta that is then multiplied by the velocity. What is delta?

The game engine attempts to run at a consistent 60 frames per second. However, this can change due to computer slowdowns, either in Godot or from the computer itself. If the frame rate is not consistent, then it will affect the movement of your game objects. For example, consider an object set to move 10 pixels every frame. If everything is running smoothly, this will translate to moving 600 pixels in one second. However, if some of those frames take longer, then there may only have been 50 frames in that second, so the object only moved 500 pixels.

Godot, like most game engines and frameworks, solves this by passing you delta, which is the elapsed time since the previous frame. Most of the time, this will be around 0.016 s (or around 16 milliseconds). If you then take your desired speed (600 px/s) and multiply by delta, you will get a movement of exactly 10. If, however, the delta increased to 0.3, then the object will be moved 18 pixels. Overall, the movement speed remains consistent and independent of the frame rate.

As a side benefit, you can express your movement in units of px/s rather than px/frame, which is easier to visualize.

主站蜘蛛池模板: 饶平县| 分宜县| 马鞍山市| 泾源县| 洪江市| 大庆市| 和政县| 黎川县| 玛多县| 喀什市| 彰武县| 边坝县| 海伦市| 定日县| 佛坪县| 怀仁县| 兰考县| 韩城市| 新巴尔虎左旗| 绍兴市| 太谷县| 闻喜县| 白玉县| 麻栗坡县| 三穗县| 柳州市| 达日县| 措美县| 松滋市| 松原市| 喀什市| 中牟县| 常山县| 白山市| 湘西| 浦东新区| 察雅县| 松江区| 玛纳斯县| 当阳市| 天柱县|