Hi,
I have written a program where I place a ball on a floor, and I have used classes like RigidBodyControl and BulletAppState to get physics simulation.
If I have only ball and not floor then ball just free falls which is expected. And if I program such that floor is tilted then again ball just rolls down the slope.
But if I program for user input so that on pressing a key the floor tilts then I am not getting this rolling effect, ball just remains where it is.
Any idea why thismay be happening.
Manish
when i saw the title i was like “superman much?”
do [java]floor.getControl(RigidBodyControl.class).setKinematic(true);[/java] and move it with rotate(), and see what happens
Add
[java]
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
[/java]
to your simpleInitApp and it will show you what the real physics object is
My guess is your moving the mesh and the physics object is staying in the same place.
floor.getControl(RigidBodyControl.class).setKinematic(true);
didn’t work.
bulletAppState.getPhysicsSpace().enableDebug(assetManager)
crashes for me.
Do you “setApplyPhysicsLocal(true)” somewhere? I had the effect you describe when doing that (just to test what it does).
no i didn’t…so i did it, but still no change…
here is my code
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
sphere = new Sphere(32, 32, 0.1f, true, false);
Geometry sphere_geo = new Geometry(“Sphere”,sphere);
Material sphere_mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
sphere_mat.setColor(“Color”, ColorRGBA.Gray);
sphere_geo.setMaterial(sphere_mat);
rootNode.attachChild(sphere_geo);
sphere_geo.move(0,.1f,0);
ball_phy = new RigidBodyControl(1f);
sphere_geo.addControl(ball_phy);
bulletAppState.getPhysicsSpace().add(ball_phy);
floor = new Box(Vector3f.ZERO,2f,0.1f,2f);
floor_geo = new Geometry(“Floor”,floor);
Material floor_mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
floor_mat.setColor(“Color”, ColorRGBA.Green);
floor_geo.setMaterial(floor_mat);
rootNode.attachChild(floor_geo);
floor_phy = new RigidBodyControl(0.0f);
floor_geo.addControl(floor_phy);
if(floor_geo.getControl(RigidBodyControl.class)!=null){
((RigidBodyControl)floor_geo.getControl(RigidBodyControl.class)).setKinematicSpatial(true);
((RigidBodyControl)floor_geo.getControl(RigidBodyControl.class)).setApplyPhysicsLocal(true);
}
bulletAppState.getPhysicsSpace().add(floor_phy);
anyone having any idea?
i set mine to kinematic, and rotate my floor with normal .rotate() methods, and it works fine
is location of code an issue…above code is in simpleInitApp
and in onAction i have placed
floor_geo.rotate(0,0,FastMath.HALF_PI/8);
use setKinematic(true) not setKinematicSpatial
i use:
[java]
CollisionShape shape = CollisionShapeFactory.createMeshShape(tiltingDome);
RigidBodyControl control = new RigidBodyControl(shape, 0);
control.setFriction(5f);
tiltingDome.addControl(control);
tiltingDome.getControl(RigidBodyControl.class).setKinematic(true);
bulletAppStateScreen.getPhysicsSpace().add(tiltingDome);
rootNodeScreen.attachChild(tiltingDome);
[/java]
and in onAnalog
[java] tiltingDome.rotate(0, 0, value); [/java]
hi wezrule…it worked.
thanks a lot buddy.