Hello Monkeys.
I’ve been trying to setLocalTranslation of a spatial with a RigidbodyControl, But whenever I set the translation via the spatial, the physics doesn’t seem to work.
I’ve also tried to use setPhysicsLocation with a Rigid body node with the spatial, but the object doesn’t move to the location.
It’s a bit unclear how I should set the location of a static rigid body, thanks for any input!
spatial.getControl(RigidBodyControl.class).setPhysicsLocation(newLocation); should work, are you sure you don’t use the empty constructor?
Thanks normen, works great now!
Here is a sample of setting the translation of a static object with rigid body.
[java]
skinnyTree = assetManager.loadModel("Models/Foliage/GameTreeSkinny_1.j3o");
// creates a MeshCollisionShape automatically, based on mass=0
skinnyTree.addControl(new RigidBodyControl(0));
skinnyTree.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-24.0f, 2.8f, -30.0f));
// finds the attached control and adds it to the PhysicsSpace, adding the control itself would work as well
bulletAppState.getPhysicsSpace().add(skinnyTree);
rootNode.attachChild(skinnyTree);
[/java]
Edit: added a missed line.
In the code above, haven’t you forgotten to attach treePhysicsNode to skinnyTree somehow ?
abies said:
In the code above, haven't you forgotten to attach treePhysicsNode to skinnyTree somehow ?
Edited the above post. overlooked a piece :)
Edited the above post to make it even less code
Cheers!