Optional "double Physics Speed" Button?

Let’s say my game is clocked at 30 FPS and everything is finetuned to it, but now in the game I want to give the player a “fast speed” button. Pressing it would result in everything (my manual movements, the physics movements) to be doubled in speed. How would this be possible, if at all?

For my own manual movements it’s easier, as I just need to add some factor to multiply all internally handled speeds and intervals. But for the physics objects? I can’t just double velocities as that would also change all trajectories and bounces and stuff, which I want to keep steady – it should do nothing else but fast-forward.

Any help appreciated, thanks!

Hi there,

Try playing around with physics.setTimeStep() (http://docs.coronalabs.com/api/library/physics/setTimeStep.html).  I think it’s able to do what you have in mind.

 

  • Andrew

Thanks, sounds very good!

Hi! I noticed that setting things faster using e.g. physics.setTimeStep(.1) will also change the path (the faster, the more different the path). Is there any way to avoid that trajectory change?

Hi.  I haven’t played with that feature much myself, so I’m not sure.  You might also want to try changing the gravity force at the same time you change the time step, i.e., faster time step, but stronger gravity, so that the trajectories don’t change.

Interesting. Though I think I don’t really understand what timeStep is doing then. I had figured it wouldn’t change actual velocity and such, but only execution speed. Hmm…

I completely agree, I wouldn’t think changing the gravity would be necessary either.  It was more just a thought about how to coax it into doing what you’re looking to achieve.  :-)

You might want to take a look at this thread from last year when the feature was introduced: http://forums.coronalabs.com/topic/16377-how-to-slow-box2dphysics-down/?hl=%2Bmax+%2Bpayne.

Thanks, I’ll play around with it, and that thread is also helpful.

Does anyone per chance know what the second mystery parameter passed to setTimeStep is? http://docs.coronalabs.com/api/library/physics/setTimeStep.html

Hi there,

Try playing around with physics.setTimeStep() (http://docs.coronalabs.com/api/library/physics/setTimeStep.html).  I think it’s able to do what you have in mind.

 

  • Andrew

Thanks, sounds very good!

Hi! I noticed that setting things faster using e.g. physics.setTimeStep(.1) will also change the path (the faster, the more different the path). Is there any way to avoid that trajectory change?

Hi.  I haven’t played with that feature much myself, so I’m not sure.  You might also want to try changing the gravity force at the same time you change the time step, i.e., faster time step, but stronger gravity, so that the trajectories don’t change.

Interesting. Though I think I don’t really understand what timeStep is doing then. I had figured it wouldn’t change actual velocity and such, but only execution speed. Hmm…

I completely agree, I wouldn’t think changing the gravity would be necessary either.  It was more just a thought about how to coax it into doing what you’re looking to achieve.  :-)

You might want to take a look at this thread from last year when the feature was introduced: http://forums.coronalabs.com/topic/16377-how-to-slow-box2dphysics-down/?hl=%2Bmax+%2Bpayne.

Thanks, I’ll play around with it, and that thread is also helpful.

Does anyone per chance know what the second mystery parameter passed to setTimeStep is? http://docs.coronalabs.com/api/library/physics/setTimeStep.html