New StepPhysics Plugin API

Hey Creators,

We’re thrilled to introduce the latest addition to Roblox Studio: the WorldRoot:StepPhysics API. This powerful new plugin-level API is part of our ongoing efforts to improve the usability of the Roblox Physics Engine and is designed to make creating physics-based systems easier and faster.

What is WorldRoot:StepPhysics?

The StepPhysics function enables you to advance the world, or part of it, forward by a specified amount of time. This functionality is available on both the Workspace and WorldModels. The API accepts two arguments: a timestep and an optional set of parts. The physics solver in Roblox will then simulate the specified parts, moving them accordingly.

Please keep in mind that this API has Plugin Security, meaning you won’t be able to use it in published experiences.

Key Features:

  • Single Step Simulation: Advance your world by a single step with precise control over the timestep and the parts to simulate.
  • Flexible Application: Use StepPhysics during both Play tests and Edit time for versatile debugging and design workflows.
  • Partial World Simulation: Specify a subset of parts to simulate, enabling focused and efficient debugging.

Example Use Cases:

workspace:StepPhysics(1.0/60.0)

This advances all the parts in the workspace and any world models forward by 1/60th of a second. This is equivalent to a simulation step that is performed when a game is running normally.

workspace:StepPhysics(0.001)

This advances all the parts in the workspace and any world models forward by 1 millisecond. This is similar to a normal simulation step but advances things forward by a smaller time increment.

workspace:StepPhysics(1.0, {workspace.Part1})

This simulates the behavior of Part1 for 1 second while treating everything else in the workspace as fixed. Any parts connected to Part1 through constraints will be treated as anchored during the simulation; however, any parts in the same assembly will automatically be included in the simulation. Note that although the simulation will take many individual steps, the results will not be visualized until the duration is complete.

simulationJob = game:GetService("RunService").RenderStepped:Connect(function(dt)
workspace:StepPhysics(dt)
)

This advances the parts in the workspace forward by a time dt for each render step that is performed. This will give the appearance that the simulation is “running” as normal but with more flexibility over the timescale of the simulation and the parts to be included in it.

Example Scenarios:

  • Design Plugins: Create plugins that accelerate the design of physical mechanisms.
  • Debugging: Use StepPhysics during Play tests to debug and refine complex interactions.
  • Previewing Motion: Preview the motion of mechanisms during Edit time for immediate feedback as you adjust parameters.
  • Natural Placement: Use physics to place objects naturally, like hanging a rope bridge or piling debris.

What’s Included When You “Step”?

When called during a play test, the StepPhysics function simulates:

  • Unanchored parts
  • Animation tracks and rig positions
  • Events such as PreSimulation, PostSimulation, and PreAnimation

During Edit time, only code defined in a plugin or executed from the command bar will run, ensuring scripts do not start automatically.

Example Plugin

To demonstrate the preview and debugging applications of this API, we are publishing a plugin which can be found here. With this plugin, you can preview the motion of a set of parts in the world by stepping the simulation forward in individual steps or running the simulation for a specified amount of time in a loop. While the simulation is running, you can adjust constraint parameters or add additional parts to the simulation to see how new components will interact with the system.

To start using this plugin:

  1. Click here
  2. Click on Get Plugin.
  3. Click on Try in Studio (Studio should open automatically).
  4. Click Install within the Toolbox window
  5. Click on the Plugins Tab
  6. And select the StepPhysics Demo (the GUIs will show up in the 3D viewport)

You can also search for the StepPhysics Demo plugin straight from the Toolbox in Studio.

image1

Adding parts iteratively to the selective simulation set: start with the propeller blades, then add the base, and lastly add the humanoid.

image3

Settling a pile of rectangular prisms for a more organic layout.

image2

Settling a rope bridge to its natural rest state.

Leveraging this Plugin

The plugin also has the ability to copy itself into an experience’s ReplicatedStorage, allowing you to view the source code directly.

You can do this by clicking on Add Plugin Source Code to Replicated Storage (found in the top of the screen when having the StepPhysics Demo plugin enabled). After doing so, you should see a StepPhysics folder in Replicated Storage that contains the Script and ScreenGui used to make the plugin.

Our hope is that this plugin may inspire the development of more sophisticated and varied tools by the community. We encourage you to experiment with the StepPhysics API and share your innovative plugins with the community.

Stay tuned for more updates and exciting features coming your way. As always, we value your feedback and are here to support you. If you have any questions, concerns, or requests, please let us know!

Best,
M0bsterLobster

129 Likes

This topic was automatically opened after 10 minutes.

Wow this is so cool! I could really add this to my plugin which already has a selective physics feature by doing some really hacky stuff (putting all parts in a WorldModel). But now with this function I can really easily selectively simulate a set of parts. Thanks a lot!

(Edit: I am not advertising my plugin, this seriously makes a great change to my plugin since this update is intended for plugins like mine :slight_smile: .)

3 Likes

This API should be accessible to normal scripts. Do not ask me why, you know why.

42 Likes

Yeah this would be huge for server authoritative stuff

7 Likes

Can’t think of too many use cases in the current state, but if they allow this to be used on live servers it would be an actual complete game changer

6 Likes

This is fantastic; I will definitely use it to create amazing things!

1 Like

No slow-motion engine for us, darn.

11 Likes

Is there a problem with the parts: {Instance}? parameter of StepPhysics currently? Sometimes when I try using it (ex. providing it a part in a table), it does nothing to the part. If I just call the method without providing that parameter, the part moves like expected.

You can see at the end of the video that one of the balls doesn’t want to move. It feels as though sometimes the parts are going to sleep and not waking up.

7 Likes

This would be absolutely game changing.
Is there any possible sliver of hope this may be worked on for use in live games?

5 Likes

For some reason, if you have only one unanchored part, using the table won’t work. If you have more than one, it acts normal.

1 Like

Now we need a plugin to slow down or reverse the simulation!

Great job!

1 Like

the blatant advertising here is wild
other than that, great new plugin API. physics simulation without running a session is quite interesting

3 Likes

I am not advertising my plugin here. I just wanted to let the staff know that this update will have a positive impact on my plugin. They encourage this behavior. But I appreciate your concern! :slight_smile:

4 Likes

YES! PHYSICS BAKING! CUTSCENES!
Now runtime access to the physics API.

3 Likes

This update is a massive W! I was looking forward to it! Amazing work!

but… PLS enable it for normal scripts too :pray:
Do you guys have any plans for that?

4 Likes

Please let us use this in live games. :pray:

Desperately need the ability to create slow-motion effects, I honestly don’t want to re-invent an entire physics engine from scratch just to do that on the client.

But I currently have to just to implement things like time-stop or dramatic effects (such as slowing down time before a group of enemies is exploded by a rocket for instance or boss crashing into the arena through a wall).

7 Likes

Now all we need is the ability to use this in LocalScripts

5 Likes

This post really got me excited until I read that it’s in Studio only and is meant to be used for debugging purposes. If this was a thing I could use in my games themselves, it would solve so many issues I’ve had with physics simulations for years that make so many of my ideas completely obsolete.

4 Likes

We need this in live experiences! I have many plans to do server-authoritative stuff, and many cool game mechanics that I need this for.

4 Likes