Question on BindToRenderStep and similar syntaxes

The format for BindToRenderStep is

RunService:BindToRenderStep("foo", 0, bar)

It seems odd to me that it doesn’t instead use an object.

local foo = RunService:BindToRenderStep(0, bar)

Or something to that effect. A similar example that’s actually in the API would be

local animationTrack = Humanoid:LoadAnimation(animation)

It’s as if RunService creates an object under the hood but then you can only manipulate it through the service. Is there any particular reason for this?

Adding an object for everything that seems like it should have one would be API bloat.

The only options you are given are to bind a function to RenderStepped at a certain priority and unbinding it. You aren’t actually creating anything, you’re binding a function towards a certain action. Similar behaviours can be observed with ContextActionService and BindToClose. It is more likely that a table of functions is made internally that is ran when a specific condition is met over an object being created under the hood (nothing in the API suggests an object is created).

LoadAnimation actually parses animation data from an Animation object and creates an AnimationTrack for which several members and properties exist in order to be able to modify them. The creation of an object makes sense for this scenario since there’s a list of API to be used to modify the object.

1 Like