What’s the difference between PostSimulation
, Heartbeat
, and PreRender
? What happens between PostSimulation
and Heartbeat
? What happens between Heartbeat
and PreSimulation
?
It says that Heartbeat fires every frame, after the physics simulation has completed, but it says that PostSimulation also fires every frame, after the physics simulation has completed.
postsimulation
- this event fires immediately after the physics simulation for the frame is complete, but before rendering. this is ideal for tasks that depend on updated physics states, such as adjusting the positions or properties of objects that have been affected by forces, collisions, or other physics-based events. since the physics calculations are complete by this point, you can make any adjustments based on the new state of the game world.
heartbeat
- the
heartbeat
event fires after postsimulation and just before the prerender event. it is called once per frame, regardless of frame rate. this is generally used for operations that need to be in sync with the frame rendering process, such as handling smooth animations, controlling character movement, or adjusting gameplay elements like camera positioning or dynamic object behavior. the code executed here is intended to run just before the frame is rendered.
prerender
- the
prerender
event fires immediately before the frame is rendered to the screen. it is the last point in the frame cycle where you can update visual elements. this is perfect for final visual adjustments, such as modifying the camera view, applying post-processing effects, or adjusting ui elements right before the frame is drawn. this event is useful for last-minute changes that affect the visual output without affecting the game’s internal logic.
what happens between these events?
- between postsimulation and heartbeat: after physics calculations are done, the game state is stable, and the world has updated. this is when you would make adjustments based on physics results, but before the frame is drawn, allowing for logic updates that prepare the scene for rendering.
- between heartbeat and prerender: the heartbeat handles smooth, frame-specific updates like animations and camera movements. the prerender event enables us to adjust visual elements before they appear on the screen, allowing for visual transitions or final ui tweaks.
soo yeahh in short we’ll remember it as
-
postsimulation: physics updates
-
heartbeat: gameplay updates
-
prerender: visual updates
-
postsimulation to heartbeat: physics to gameplay
-
heartbeat to prerender: gameplay to visuals
hope this helps!
Based on that chart, I can see that the server processes input between Heartbeat and PreRender, but I don’t understand the “queue delayed scripts” part between PostSimulation and Heartbeat.
Never mind. I just saw another reply. I’m gonna read it.
1 Like