Rigid bodies seem to stop for no reason (Solved, ”sleeping threshold” defaults a bit high for my app

I just started experimenting with physics in my game (Gravity Arena)



I started to implement physics, starting with just my asteroid objects. Things seemed to be working fine, but sometimes the asteroids stop for no reason (that I’ve been able to detect). If something else bumps them, they move again, but usually they will later stop once more.



I just updated my applet so you can see the problem if you wish to look.



Here’s the relevant code:





In the main class:



[java]

//init Physics

bulletAppState = new BulletAppState();

stateManager.attach(bulletAppState);

bulletAppState.getPhysicsSpace().setGravity(Vector3f.ZERO.clone());

[/java]



In the node I am implementing physics for:



[java]

this.physics = new RigidBodyControl

(new SphereCollisionShape(size/2f),

(float)(material.density()*(4f/3f)FastMath.PIMath.pow(size/2f,3f)));

this.physics.setDamping(0, 0);

this.addControl(physics);

thisApp.bulletAppState.getPhysicsSpace().add(physics);

[/java]



A bit later than that I do asteroid.physics.setLinearVelocity(some vector);

and let it loose.

They will be deactivated when they don’t move enough for some time. Just use [java]physics.activate()[/java] to activate them again. I didn’t found a setting to disable this behavior completely.

1 Like
@Lockhead said:
They will be deactivated when they don't move enough for some time. Just use [java]physics.activate()[/java] to activate them again. I didn't found a setting to disable this behavior completely.


Yeah I guess running physics.activate() on it every frame could work, but there's got to be less of a dirty hack solution. Anyone else have an idea?

In native bullet you can set the sleeping threashold. At least the lower level jme binding works fine, not sure about the controller stuff tho)

2 Likes
@EmpirePhoenix said:
In native bullet you can set the sleeping threashold. At least the lower level jme binding works fine, not sure about the controller stuff tho)

Okay, I'll look up sleeping threshold and see if I can figure that out.
@EmpirePhoenix said:
In native bullet you can set the sleeping threashold. At least the lower level jme binding works fine, not sure about the controller stuff tho)


physics.setSleepingThresholds(0, 0);

That did the trick nicely.

Once I'm using damping factors, I'll probably put in a small sleeping threshold again, but now I know about the feature and all's well.

Anyway thanks a lot, you win the helpfulness prize :P
1 Like