Responsive Tilt

I’m looking for a way for my game to have a very responsive left, right tilt.

I’ve set friction to 0.0 and density to 2 (i’ve tried various settings). I also tried moving gravity though various settings.

For example:

physics.addBody( mySpriteInstance, “dynamic”, { density=2.0,friction=0.0 } )
function onTilt( event )
–9.8 is similar to earth gravity… may need to adjust
physics.setGravity( (30 * event.xGravity ), 0 )
end

Can anyone recommend some good settings? It seems there is still some lag when I tilt left and right.

Thanks!! [import]uid: 4438 topic_id: 4134 reply_id: 304134[/import]

Have you set the accelerometer frequency? Using “system.setAccelerometerInterval( 75 )” will set the frequency of the accelerometer to 75, values can be between 10 and 100, the higher the value the greater sensitivity in the tilt events.

http://developer.anscamobile.com/reference/index/systemsetaccelerometerinterval

-Clark [import]uid: 5786 topic_id: 4134 reply_id: 13094[/import]

Hi Clark,

I had that set to 100 - but it’s still a bit sluggish.

[import]uid: 4438 topic_id: 4134 reply_id: 13271[/import]

Would this have any impact (Is this needed just to move left, right responsively based on tilt)?

mySpriteInstance:setLinearVelocity( 1000, 0 )
mySpriteInstance n:applyForce( 1500, 0, mySpriteInstance.x, mySpriteInstance.y )

I’ve tried this with a few different settings - not having much luck. [import]uid: 4438 topic_id: 4134 reply_id: 13274[/import]

Mmm, not really sure…I am still very new to corona but this is what I have to move my car left and right across the screen and it works just fine.

system.setAccelerometerInterval( 70 )  
function onTilt( event )  
 car.x = (car.x - event.yGravity \* 30)  
end   
  
Runtime:addEventListener( "accelerometer", onTilt )   

Maybe some of the more seasoned Corona developers can weigh in and help you out, as I am still very new to this. Sorry I couldn’t help more!

-Clark [import]uid: 5786 topic_id: 4134 reply_id: 13276[/import]

Perhaps that’s what I’m doing wrong. I was letting gravity do the work, instead of moving the object by setting it’s x coord.

I’ll give that a try. Thanks! [import]uid: 4438 topic_id: 4134 reply_id: 13278[/import]