Roblox BlindToRenderStep function binds the custom function to be called at the certain time during the render step. There are three main arguments for BlindToRenderStep, including “name”, “priority”, and the thing called “what function to call”. As this one is linked to the rendering process of the client. BlindToRenderStep is only able to be called on the client.
The name parameter is known as the label for binding and can be used with RunService: UnbindFromRenderStep if the binding is no longer needed. For the priority of the binding, it is an integer and determines when during the render step in order to call the custom function. Basically, the lower this number, the sooner the custom function will be called. If there are two bindings that have the same priority, the Roblox engine will randomly pick one to run first.
Here are the default Roblox control scripts run with those specific priorities:
- Player Input: 100
- Camera Controls: 200
Do not forget that for the convenience, the RenderPriority enum can be used to determine the integer value to set a binding. For instance, in order to make the binding right before the default camera update, you can simply subtract 1 from the camera priority level. Please take a note that when using Enum.RenderPriority, you have to use InlineCode.Value at the end of the desired enum. In fact, BindToRenderStep will not work if just the enum on its own is used.
The last argument of the thing called BindToRenderStep is the custom function to call. This one will be passed one parameter named deltaTime. For your information, deltaTime shows how much time passed between the beginning of the previous render step and the beginning of the current render step. Please remember that all rendering updates will wait until the code in the render step finishes. In this case, please make sure that any code called by BindToRenderstep runs quickly and efficiently. In case the code in BindToRenderstep takes too long, then the game visuals will be choppy.
This paragraph will talk about the code samples. One of them is frame moving in circle. This one moves a GuiObject in the circle within its parent object using the BindToRenderstep of Run Service. this defines the parametric equation in the function in order to help with positioning the GuiObject. In order to try this code out, you have to put the ScreenGui in the StarterGui. Inside the thing called ScreenGui, you have to insert the Frame with the LcoalScript. Then, paste the code into the LcoalScript and play the game. In the end, you can watch the Frame travel counterclockwise within. Aside from frame moving in circle, there are bind and unbind the function and RunService custom function. The example of bind and unbind the function uses the RunService to bind and unbind the function named printHello. First of all, you bind the function to the RenserStep so that fires every step. Then, after you wait 5 seconds, you unbind the function.