Reverse Gravity According to Device Orientation

I’m struggling with reversing the gravity dynamically when the device is in “portraitUpsideDown” orientation.

The code I have only works in portrait.

function onTilt( event )  
 if (system.orientation) == portraitUpsideDown  
 then  
 physics.setGravity( 5 \* event.xGravity, 10 \* event.yGravity )  
 else  
 physics.setGravity( 5 \* event.xGravity, -10 \* event.yGravity )  
 end  
end  

Thanks for taking a look!
[import]uid: 10763 topic_id: 17287 reply_id: 317287[/import]

When the system orients, try swapping the xGravity and yGravity (or play around with the values), see if that works. [import]uid: 52430 topic_id: 17287 reply_id: 65337[/import]

@jonathanbeebe I thought my code was swapping the gravity properly. That’s where I’m stumped.
Thanks! [import]uid: 10763 topic_id: 17287 reply_id: 65417[/import]