Slow down acceleration

Does anyone know how to, when I’m accelerating an object by tilting the phone, then While returning the phone to its original state the ball slowly stops accelerating?

Because right now when I tilt the phone, it accelerates, then when I’m slowly returning the phone’s gravity to 0 again, then ball keeps accelerating until at < 0, I’d just like it to slowly stop accelerate while I’m slowly returning the phones gravity to 0

Thanks in advance :slight_smile: [import]uid: 14018 topic_id: 5547 reply_id: 305547[/import]

vx, vy = playerObject:getLinearVelocity()  
playerObject:setLinearVelocity( 10 \* yGravity, vy )  

Put that inside your accelerometer function, and change 10 to affect the acceleration.

Hope that helps :slight_smile:

// Ed.
[import]uid: 7143 topic_id: 5547 reply_id: 18805[/import]

Thanks once again Ed! But I’m assuming this code only works for the y-coordinate? Is there any way to apply this code to both x and y?

Thanks! [import]uid: 14018 topic_id: 5547 reply_id: 18806[/import]

You’re welcome :slight_smile:

The same method should work for the x coordinate as well. Try this out:

vx, vy = playerObject:getLinearVelocity()  
playerObject:setLinearVelocity( 10 \* yGravity, 10 \* xGravity )  

// Ed [import]uid: 7143 topic_id: 5547 reply_id: 18812[/import]

Hmm, that made both the x and the y slow. With the other code the y works [import]uid: 14018 topic_id: 5547 reply_id: 18814[/import]

Try changing the 10 in “10 * yGravity” to see if that makes a dfference.

// Ed [import]uid: 7143 topic_id: 5547 reply_id: 18816[/import]

edit: Fixed it :slight_smile: Thanks! [import]uid: 14018 topic_id: 5547 reply_id: 18818[/import]