You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dreamlab runs at a fixed, customizable tickrate. By default, the engine will tick 60 times a second. During a tick, the
8
-
engine will update entities and run the `onTick` functions in your [Behavior scripts](behaviors.mdx). A fixed tickrate
9
-
is advantageous because it means you don't have to constantly refer to a delta time eveywhere in your scripts and makes
10
-
networking simpler.
8
+
Dreamlab simulates the **game world** at a **fixed tick-rate** (60 TPS by default).
9
+
Every tick the engine
11
10
12
-
## Ordering
11
+
1. advances physics & transforms,
12
+
2. executes your **Behavior** callbacks,
13
+
3. sends a network snapshot, and then
14
+
4. uses **interpolation** to render buttery-smooth frames on any monitor refresh rate.
13
15
14
-
During a tick, the following happens:
16
+
A fixed tick-rate keeps gameplay deterministic and makes networking much simpler—most of the time you don't even need `deltaTime`; the engine handles it for you.
15
17
16
-
1. All entities tick, updating their visuals, physics bodies, tranform, etc.
17
-
2. All Behaviors run their `onTick` methods
18
-
3. All Behaviors run their `onPostTick` methods
19
-
4. Entities and their attached Behaviors under the `world` tree is synced over the network
20
18
21
-
Behaviors do not tick in a guaranteed order. If you absolutely need to guarantee that one Behavior ticks before the
22
-
other, it's recommended you refactor your code to enforce ordering using function calls; for example the following is
|**onPostTick**| “Late update” logic (e.g., camera follow) |
28
+
| Network snapshot | Sync entities in the **`world`** root |
29
+
|**onFrame***(client)*| Extra rendering per display frame (optional) |
30
+
31
+
> The order **onPreTick → onTick → onPostTick** is guaranteed;
32
+
> within each band, Behaviors execute in an undefined order.
33
+
34
+
35
+
36
+
### `onTick` vs `onPostTick`
37
+
38
+
Think of a tick as “prepare the next world state”:
39
+
40
+
***`onTick`** - move players, run AI, update health bars.
41
+
* Physics resolves all overlaps.
42
+
***`onPostTick`** - world state is final → update camera, parallax, etc.
43
+
44
+
45
+
46
+
Behaviors do not tick in a guaranteed order. If you absolutely need to guarantee that one Behavior ticks before the other, it's recommended you refactor your code to enforce ordering using function calls; for example the following is **incorrect**:
24
47
25
48
```ts
26
49
classBehaviorOneextendsBehavior {
@@ -38,31 +61,49 @@ class BehaviorTwo extends Behavior {
0 commit comments