Practical Uses for Heartbeat and RenderStepped

Recently I’ve been experimenting with RunService, specifically with Heartbeat and RenderStepped. As I understand it, they both run on every frame except Heartbeat runs after the physics simulation and RenderStepped runs before it. Would there be any situations where one is more practical than the other?

1 Like

I’m not very advanced with the two, but I know when doing things such as changing a parts CFrame to the camera’s you should use :RenderStepped() instead of :Heartbeat(). I would have thought, like the reason you said, it’s because it runs before the physics simulation.

I don’t think render frames are always in sync with physics simulation

I use it for custom wait, since Roblox’s wait is not very accurate…

EDIT: Sorry wrong reply, this is for @Meisrcool

I think you should use RenderStepped when the situation depends on visuals, refreshing every frame to always keep it in good look, while using Heartbeat when your situation depends on physics, like make a raycast everytime physics are calculated, etc

That’s a good idea I didn’t think about raycasting

Check out

… to see what the different things actually are.

Here’s a test file place you can use to see why it can matter: CamTest.rbxl (26.3 KB)

The camera rigidly follows a physics- simulated Part (CameraPart) while a different, anchored Part follows the camera (updates on Heartbeat).

Just test it and press F to cycle between 3 different modes (open the Output window to see which). Wait a few seconds for the CameraPart to start moving.

When updating the camera on Stepped, both the center part and the follower looks really choppy, because they don’t update in sync.

When updating on RenderStepped the follower looks choppy because it updates on Heartbeat, so it’s not in sync with the camera. AFAICT it updates one render frame after the RenderStepped on which the camera was updated.

When updating on Heartbeat everything looks perfectly smooth.

This doesn’t mean that Heartbeat or RenderStepped is better for updating the camera, you could make RenderStepped look smooth by updating the follower on RenderStepped as well. It’s just something to be aware of because it can mess things up.