timer.performWithDelay() bug, physics does not work correctly in the latest version of corona sdk

Physics does not work correctly in the latest version of corona sdk Corona 2018.3378:

applyAngularImpulse

applyTorque

applyForce

Act with much greater force. When set to -1, the timer does not work properly. In Corona 2018.3326 works correctly.

require "physics" physics.start() physics.setGravity( 0, 0 ) local box = display.newRect(100,100,50,50) box:setFillColor(1,0,0) physics.addBody(box, "dynamic", { density = 0.1, friction = 0.8, bounce = 0} ) function update(event) box:applyAngularImpulse( -1 ) --box:applyTorque( -1.2 ) --box:applyForce(-3,0,box.x,box.y) end timer0 = timer.performWithDelay( 1, update,-1 )

It’s not so much that physics doesn’t work, it’s that your update function may be getting called more often than before.

Remember, timer.performWithDelay can only trigger functions in time with the framerate of the app. So when setting to 1ms, it will actually trigger every 16.667 ms, providing your app is set to 60 fps and other code is not heavy duty enough to reduce the framerate below 60.

There was a change in 2018.3366 with the note: “Framework: making iterating timer more precise”. This sounds like something that might change how repeating timers are called.

In addition to what @nick_sherman already said, since you are applying angular impulse, torque and force every frame, it’ll mean that if there is any variation in the frame rate due to the OS doing something in the background or the app itself lagging a bit, then the rate at which the physics forces are applied varies as well. 

In what function then to cause?

If you apply torque (or any other physics forces) to an object so frequently, then it’ll keep speeding up until it moves so fast that the object itself will appear stationary (or it’ll just fly off the screen, never to been seen again), which I’m guessing isn’t the intended behaviour?

Typically, you want to tie applying force to an object to some event instead of infinitely looping 1ms timer.

I have so implemented the management of the character in the game Draw Rider. In the cycle, pressing the control buttons is checked.

It’s not so much that physics doesn’t work, it’s that your update function may be getting called more often than before.

Remember, timer.performWithDelay can only trigger functions in time with the framerate of the app. So when setting to 1ms, it will actually trigger every 16.667 ms, providing your app is set to 60 fps and other code is not heavy duty enough to reduce the framerate below 60.

There was a change in 2018.3366 with the note: “Framework: making iterating timer more precise”. This sounds like something that might change how repeating timers are called.

In addition to what @nick_sherman already said, since you are applying angular impulse, torque and force every frame, it’ll mean that if there is any variation in the frame rate due to the OS doing something in the background or the app itself lagging a bit, then the rate at which the physics forces are applied varies as well. 

In what function then to cause?

If you apply torque (or any other physics forces) to an object so frequently, then it’ll keep speeding up until it moves so fast that the object itself will appear stationary (or it’ll just fly off the screen, never to been seen again), which I’m guessing isn’t the intended behaviour?

Typically, you want to tie applying force to an object to some event instead of infinitely looping 1ms timer.

I have so implemented the management of the character in the game Draw Rider. In the cycle, pressing the control buttons is checked.