[SOLVED] Instant change of direction with accelerometer + physics?

Hi everyone!

I’m working on an accelerometer controlled game where the player controls the gravity to move an object around.

How a left & right controllable environment works:

[lua]
local function onAccelerate( event )
if event.yGravity > 0.1 then
physics.setGravity(-15, 10)
else if event.yGravity < -0.1 then
physics.setGravity(15, 10)
else
physics.setGravity (0, 10)
end
end
end
[/lua]

Pretty simple, now what happens is that the object decelerates before changing direction, which is logical as we’re talking about physics. But my question is: would it be possible to make the shift of direction instant? I’m thinking some sort of temporary directional velocity added to the object in question, but would need a helping hand here.

Thanks in advance :slight_smile: [import]uid: 56195 topic_id: 37607 reply_id: 67607[/import]

Have you played with x/y/zInstant instead of x/y/zGravity? They might give you better numbers you need to play with to get the desired result.

http://docs.coronalabs.com/daily/api/event/accelerometer/index.html

[import]uid: 6084 topic_id: 37607 reply_id: 145802[/import]

Wow, what a mistake, I remember giving up on instants but this time they were just what I needed.

Thanks!
[import]uid: 56195 topic_id: 37607 reply_id: 145812[/import]

Have you played with x/y/zInstant instead of x/y/zGravity? They might give you better numbers you need to play with to get the desired result.

http://docs.coronalabs.com/daily/api/event/accelerometer/index.html

[import]uid: 6084 topic_id: 37607 reply_id: 145802[/import]

Wow, what a mistake, I remember giving up on instants but this time they were just what I needed.

Thanks!
[import]uid: 56195 topic_id: 37607 reply_id: 145812[/import]