Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why use RenderStepped when you can use HeartBeat?

Asked by 6 years ago

I see a bunch of developers use the .RenderSteppedevent to run a block of code every frame. Though if RenderStepped runs it every render frame and .HeartBeat runs it every game frame, wouldn't there be no need for RenderStepped? If my understanding of the two terms is correct, running a loop with renderstepped would run code multiple times per HeartBeat, which is inefficient, since the user only sees the visible effects every HeartBeat.

The only practical usage I could see is eithier with managing physics or working with networking between client and server.

0
RenderStepped is client-side only Gey4Jesus69 2705 — 6y
0
Yes I understand that, though my question is why would you use it (on the client) when HeartBeat does it every visible game frame. LateralLace 297 — 6y

1 answer

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
6 years ago

Because, as the names imply, RenderStepped is related to rendering and Heartbeat is not.

In each frame, RenderStepped fires first, the frame waits for it to yield, then the render and stuff like heartbeat run parallel. Heartbeat fires last after physics.

So RenderStepped is the best option for render stuff, and if you are only concerned with doing stuff "every frame", RenderStepped in the worst option because rendering will yield unnecessarily. Nothing waits for Heartbeat.

Heartbeat should be used for everything unrelated to rendering.

0
Ah so apparently I was misunderstood that Heartbeat doesn't yield for code like RenderStepped and BindToRenderStep does, and it runs asynchronously, right? LateralLace 297 — 6y
0
Exactly cabbler 1942 — 6y
Ad

Answer this question