How bad is it on optimization to have multiple rendersteppeds?

image
I have a function that starts a renderstepped that manages a drones propellers, sounds, and direction tilt

since this is client sided, I want the function to run on other players drones.
for example if I had this renderstepped running on 10 other drones, is this bad for optimiztion?
If it is, what should I try to do to not affect optimization? try to manage all drones in one renderstepped?

Use Heartbeat instead of RenderStepped

1 Like

okay thanks
will having a heartbeat loop per drone be bad for performance (10 heartbeats for 10 drones ), or would it be better to manage all drones through one heartbeat?

also your game is rly cool

RenderStepped bindings are as optimised as your code is. Never run performance heavy code in them.

1 Like

Okay

so is it fine to have 10 separate heartbeats running at same time? Or should I try to put all of it in one heartbeat

I’d say do what’s most ergonomic for you. If multiple connections for each drone is easier to work with, use that, and if a single connection that iterates over every drone feels more cohesive, than that. The difference should be negligible, especially if it’s just 10 drones.

You’d definitely want the client’s own drone to be bound right after input updates (RunService:BindToRenderStep with Enum.RenderPriority.Input.Value + 1), since it should be the most responsive, but you could probably get away with other players drones updating at a later priority or even a slower framerate, since it isn’t as imperative for them to update that often.

1 Like

Okay, thank you, I’ll do this

but Im kinda confused since others said use a heartbeat loop

Will it be fine using bindtorenderstep since im changing the priority?
does Heartbeat allow for a bind and priority too?
Which ones better here - should I use heartbeat Or bindTorenderstep

Im trying to learn the general best practice
thanks for replying

RunService.Heartbeat is a signal that fires after every physics step during a frame. There’s also RunService.RenderStepped, but generally, you’d want to use RunService:BindToRenderStep because it lets you specify at what point in the frame the callback should run, like right after input or camera updates.

Since the client drone should be as responsive to input updates as possible, you’d want the code that updates it to be right after the engine process input (why you add 1 to the priority). If you updated the drone too early or late, it may seem a bit slow or jittery for the player controlling it.

You can update other drones on something like Heartbeat because they aren’t connected to the client’s input, so any loss of responsiveness is not noticeable.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.