[Resolved] How to stop linear movement - Physics

Hi

I’d like to kow if there is a way to stop an object moving in code without pausing / stopping the physics.

For example -
I have a ball rolling down a slope.
I want to press a button that repositions the ball back a the top of the slope.
However, if I simply reposition the x,y values of the ball, it still appears to have forward momentum and therefore continues to roll.
I would like to be able to cancel the physics on it when repositioned.

I can remove / re-add the object, but this doesn’t feel very efficient and I’d like to know if there is a command / method that will do this in a better way.

Any suggestions? [import]uid: 131942 topic_id: 25720 reply_id: 325720[/import]

Try this;

[lua]ball:setLinearVelocity(0,0)[/lua]

From here: http://developer.anscamobile.com/reference/index/bodysetlinearvelocity

Peach :slight_smile: [import]uid: 52491 topic_id: 25720 reply_id: 103977[/import]

Thank you! That’s almost there!

Using that stops the linear motion (Great!), but the ball is still “rolling”, so I need to fix that as well.

I tried using applyTorque(0), but that didn’t do anything.
Can’t seem to see a command that cancels rotation.
[import]uid: 131942 topic_id: 25720 reply_id: 103982[/import]

Ah wait - got it!

.angularVelocity

Perfect! Thanks very much! [import]uid: 131942 topic_id: 25720 reply_id: 103984[/import]

No worries, well done on figuring angular velocity out too.

Marking as resolved.

Peach :slight_smile: [import]uid: 52491 topic_id: 25720 reply_id: 104152[/import]