Physical simulation speed

Hello there,

let’s say we have a simple physical simulation of a sphere bouncing on some terrain. How can I reduce speed of this animation smoothly? For example, I want to speed up a simulation from 100 percent to 130 smoothly in five seconds. How to program, realize something like that? I only found this code:

physEngine.setTimeStep (1/60);

The problem is:
X) this code changes not only the speed but also the trajectory of the ball. I want the same trajectory, only “played” at a different speed.

In Unity, it was pretty easy to do it. Here I am confused a little bit…

cc @Cedric


Here is a small PG where you can set the simulation speed:

Check line 31

Take note that simulation is dependent on time. it won’t be the same depending on your time step.


Thanks for your PG. Can you please explain what the “newTimeStep” parameter means? I couldn’t tell from the babylon.js help which unit I’m actually inserting? Milliseconds, or if I insert a framerate that is relative and variable over time, depending on the complexity of the rendering… I do not understand how to consciously insert a parameter. From the help I understand only that To slow it down, enter 1/600 for example. That’s not much :slight_smile:

Unit is second for setTimeStep.
Keep a variable in yur code that holds the value, and when needed, increase/decrease that value and set it to the physics engine.

What is your use case actually?

What is your use case actually?

I just need the ball to accelerate or slow down smoothly and the eye notices. As an example, sports shots in TV. The shutter speed slows down from 100% to 30%. How to do this?

I’m trying something like this, but I don’t see a slowdown in ball animation like in sports news :smiley: :

something like this ?

physics speed | Babylon.js Playground (

Thank you very much for the playground. … but no, my request is very different. You use a series of pulses. But I only want to use a single pulse, such as a blow to the ball, and I don’t want to change/interfere further with the animation calculation or its flight trajectory. The ball always hits the same final place. I just want to change the feeling of the ball’s flight. For example, the ball starts flying (after pulse hit) at maximum speed and hits the ground at a speed of 10% (its very slowly). Smoothly the ball changes the speed of movement for the viewer, but the trajectory of the flight is the same.

the serie of pulse is to keep an animation going while changing simulation speed. It’s an example.

You are right, we can set only one pulse within your source code:

then the slider for regulation of speed really reacts smoothly to a change in the speed of the ball. The problem is that this change in speed affects the trajectory of the movement. When I put the simulation at low speed, a smaller number of bounces also appear. The problem is that we are not regulate only the speed of the ball…, but also its trajectory. But I need one impuls for the ball to always fly to the same place no matter how I manipulate the speed. How to do it?

AFAIK, like I said, it’s not possible to get the exact same simulation while manipulating time.
Collision penetration for example are dependent on time.

So isn’t it possible to somehow manipulate the fps rendering of the whole scene?

You can slow animations or camera movement but it won’t solve the physics simulation issue.

Hello, just checking in, was your question answered? @Pavel_Hetmer