Hey guys, I’m having trouble applying RigidBodyControl to a number of the same spatial(in this case multiple gold coins). All these coins have the same mesh and material. I can walk through these coins, they should have a rigidbodycontrol but they don’t. Here is my code:
[java]
public void dropRandomItem(AssetManager assetManager, Vector3f location, int amount) {
/**
* Gold coins that drop on the ground.
*/
gold = assetManager.loadModel(“Models/Items/Gold/Cylinder.mesh.j3o”);
gold.setMaterial(assetManager.loadMaterial(“Models/Items/Gold/gold.j3m”));
goldCoins = new Node();
amountOfGold = new Spatial[50];
CollisionShape goldShape =
CollisionShapeFactory.createMeshShape((Node) goldCoins);
goldPhysics = new RigidBodyControl(goldShape, 2f);
for (int i = 0; i < amount; i++) {
amountOfGold[i] = gold.clone();
amountOfGold[i].setMaterial(assetManager.loadMaterial("Models/Items/Gold/gold.j3m"));
amountOfGold[i].addControl(goldPhysics);
amountOfGold[i].setLocalTranslation(location.add(new Vector3f(random.nextInt(5) - random.nextInt(7), random.nextInt(6), random.nextInt(3))));
amountOfGold[i].setLocalScale(0.5f, 0.5f, 0.5f);
goldCoins.attachChild(amountOfGold[i]);
game.getApp().getRootNode().attachChild(goldCoins.clone());
game.getBulletAppState().getPhysicsSpace().add(goldPhysics);
}
//
}//end of dropRandomItem
[/java]