# Stopping all movement

Hello! I would like to stop all movement on a Geometry that has a RigidBodyControl controlling it. I have tried all three of these methods in every combination and order to try and stop the movement:

[java]
this.rigidBodyControl.clearForces();
this.rigidBodyControl.setLinearVelocity(Vector3f.ZERO);
this.rigidBodyControl.setAngularVelocity(Vector3f.ZERO);
[/java]

The problem is that whenever I set the velocities to Vector3f.ZERO, the Geometry is launched a few meters in a seemingly random direction each time. However, if I set the velocities to something miniscule (like 0.01 on x, y, and z), they spin/move a tiny bit and do not launch in a random direction. This works for me, but I am curious why using Vector3f.ZERO launches the Geometry randomly, while using a value just a fraction above zero does not. Any clues?

you can do that by either removing it from the physics space (but you’ll have no collision on it) or setting its mass to 0.

@bubuche said: you can do that by either removing it from the physics space (but you'll have no collision on it) or setting its mass to 0.

The reason I am trying to stop all movement is because I have made my game so that you can click on an object to pick it up and then move it with the mouse and click again to release it. The problem is that when an object has velocity before you pick it up, once you release it, the velocity stays there. So if you picked up a falling box, once you release it, the velocity from when you picked it up remains and it will launch into the floor. So I need a way of stopping all movement, but keep the object at the same mass and keep it in the physics space. Basically just cancel out all velocities and forces acting upon it.

maybe that what you want is a join. I never used them myself, but i think that for an interaction like in amnesia you should use one.

For the very precise question about “why does the zero vector has a strange effect and a close-to-zero vector doesn’t have it”, i don’t have the answer, and i think that nobody has a real answer for that (except if you are ready to dive in the source code).
The fact is, when you try to be tricky about physics, strange things happens.

@bubuche said: maybe that what you want is a join. I never used them myself, but i think that for an interaction like in amnesia you should use one.

For the very precise question about “why does the zero vector has a strange effect and a close-to-zero vector doesn’t have it”, i don’t have the answer, and i think that nobody has a real answer for that (except if you are ready to dive in the source code).
The fact is, when you try to be tricky about physics, strange things happens.

Okay. You’re probably right that I’d have to dive into the source code to find the answer, but that sounds like a lot of unnecessary work, so I guess I’ll stick with my workaround. Thanks! I’ll check out joints and see if they could be useful to me.

what you really should do is wait for an other answer. It very late here (1h after midnight) so i am tired. Don’t dive in the source code, it’s really something you don’t want to do. Maybe provide a test case.

and you can also try setLinearDamping with a very high value (or 1f, i don’t remember if it goes from 0 to positive infinite or from 0 to 1).

or maybesomething like : first set the speed to 0, then clear force (in that order).
Honestly, there is a lot of things to try before going in the code. And removing the object from the physic space (not from the scenegraph, so you’ll still see it) could also do the trick.

@bubuche said: what you really should do is wait for an other answer. It very late here (1h after midnight) so i am tired. Don't dive in the source code, it's really something you don't want to do. Maybe provide a test case.

and you can also try setLinearDamping with a very high value (or 1f, i don’t remember if it goes from 0 to positive infinite or from 0 to 1).

or maybesomething like : first set the speed to 0, then clear force (in that order).
Honestly, there is a lot of things to try before going in the code. And removing the object from the physic space (not from the scenegraph, so you’ll still see it) could also do the trick.

Yeah don’t worry, I was never planning on actually checking out the source code. Personally the miniscule vector workaround works for me, I was just curious as to why the zero vector made it freak out. A simple curiosity is all, not an issue. I am still open to answers from others though! I tried setting the speed to 0 and then clearing forces in that order, but it results in the same weird behaviour. I haven’t thought of the linear damping trick, but it sounds like something where I would have to wait for 1 tick before resetting the linear damping back to its original value, which seems like more work than its worth, especially since I already have a solution that works for me. Thanks!