When should I set physics.gravity? And can I set gravityScale to -1?

I’m playing around with the physics stuff, trying to understand it.

I want the simulation to react to the user doing stuff to the iPad, so I put physics.gravity(Gravity) at the start of the draw() function. However, that doesn’t always seem to do what I expect it to do. Sometimes one direction doesn’t have an effect if I tilt the iPad quickly.

Also, I’d like to set gravityScale on some of the bodies to -1. The intention is that these should float. But it doesn’t quite seem to be that simple. Is there a way to do this?

Not sure why physics.gravity(Gravity) doesn’t work as expected, try to see if the Physics Lab example reacts the same.

As for gravityScale, there’s an issue where it clamps the scale factor between [0, maxFloat]. I’ve changed it to [-maxFloat, maxFloat], which will be available in the next update.

Also remember that the Gravity variable uses a low pass filter to remove instantaneous acceleration, so maybe try physics.gravity(UserAcceleration) instead if you want it to react to quick movements.

The strange reaction might have been an artefact of the fact that setting gravityScale to -1 actually set it to 0 so gravity wasn’t having an effect, but other things were (the effects were from an earlier version of my code in the other discussion, but even in that one I already had mixed in the acceleration).

Useful to know about the low pass filter. Thanks.