How do I make a when I pause a physics and resume it with zero force of gravity?

OK sorry if question sounds confusing what I’m trying to saying is when a physics ball is rolling off a steep ramp then you pause the game having the ball reset back to top. OK then when you resume the ball force is set to zero. Having the ball continue with a new speed instead of the speed it was going down the steep ramp. [import]uid: 17058 topic_id: 19681 reply_id: 319681[/import]

If it’s a button to reset the level (which it sounds like, because pausing would just pause the ball where it lay) why not have a function to simply respawn the ball? [import]uid: 52491 topic_id: 19681 reply_id: 76134[/import]

@peach your are absolutely right wow why didn’t I think of that I’m such a newbie well thanks for the help [import]uid: 17058 topic_id: 19681 reply_id: 76137[/import]

@peach but wait is this how I would respawn the object

--Function for pause button local function pause () canBeDragged = true canrotate = true physics.pause() bt.isVisible = true bt2.isVisible = false ball.x = 160 ball.y = 30 end bt2:addEventListener("tap", pause)

Because I’ve been doing that this whole time and I feel like that wrong when the ball goes down after the unpause it just rolls down with same speed as it did when I went down hill [import]uid: 17058 topic_id: 19681 reply_id: 76139[/import]

Why don’t you just set the linear velocity to 0? Then it will start to accelerate based on your gravity again? [import]uid: 12979 topic_id: 19681 reply_id: 76144[/import]

@Chan Kian Boon yes i got it thanks good day [import]uid: 17058 topic_id: 19681 reply_id: 76145[/import]

To respawn you’d actually remove the ball then create it again inside the function just like you did at the start of the game, at the top of the hill.

That said you could also do as Chang suggested and use obj:setLinearVelocity(0,0) then set the ball.x, ball.y to equal the start position as well.

Peach :slight_smile: [import]uid: 52491 topic_id: 19681 reply_id: 76150[/import]