Spatial dissapears when physics control added

[java] Spatial Fence = assetManager.loadModel("Models/mountains.j3o");

com.jme3.bullet.collision.shapes.CollisionShape sceneShape =

CollisionShapeFactory.createMeshShape((Spatial) Fence);

RigidBodyControl border = new RigidBodyControl(sceneShape, 0);

Fence.addControl(border);

bulletAppState.getPhysicsSpace().add(Fence);

[/java]



So a few days previous, I posted on how to get a character control to start off inside a box to use as a border, well now I have decided that using huge mountians around my terrain would be a better fence. The trouble is, every time I do Fence.addControl(border), the actual model does not appear in the scenegraph. I have scoured source code and cannot find a solution (or even the problem) anywhere…

This code is taken directly from helloCollision by the way, I only changed Node To Spatial in createMeshShape

Hmm, this is strange indeed. It appears to be still loading the model but it doesn’t apply the setLocalTranslation that I give it earlier, I just found it hiding under my terrain now!

No thats not strange. If you apply a physics control to your spatial then the physics control moves the spatial. If you don’t want physics to move you spatial don’t use physics or if you just want collision shapes use kinematic rigidbodies.

make sure you use setLocalTranslation() before adding the Control to the spatial, or use body.setKinematic(true) and add a mass as normen suggests