RigidBody sometimes set, sometimes doesnt

I use my mouse to set a model in the scene and the right click to place it. When I move my model, I am also updating the position of my rigidbody so that any collision between the model moving and any stationary model will render the model red, and unable to place there. What is happening right now is that sometimes when I set the model with the right click, the rigid body collision will not work. I can walk my player through the model, while others I cannot because the RigidBody decides it wants to work. I have debug on so I can see that the RigidBody is still being placed in the right position. This usually happens when the debug turns the rigidBody from pink to blue, although I’m not sure under what circumstances this is happening. Does anyone have an idea why this would happen?

Edit: Confirmed, this only happens if I place the object after the debug turns the mesh from pink to blue.

Send us more info, like, what type of rigid body you are using, kinematic ?
If you can put some code it would be nice.

Never heard of this issue, 99% sure its something in your code.

Here is the relevant parts of the code.

    public static Spatial AddModel(Vector3f position){
        s_Model = Main.s_AssetManager.loadModel("Models/tree.obj");
        CollisionShape collision = new CapsuleCollisionShape(0.5f, 1f);        
        physicsControl = new RigidBodyControl(collision, 0);
       // Main.s_TreeNode.attachChild(s_Model);
        return s_Model;

    public static void SetModel(Vector3f position){

Right clicking sets a variable PlayerSettingModel to true, and if this is true I run the move model function.

    public static void MoveModel(Camera cam, InputManager inputManager, Spatial scene)
    if(PlayerSettingModel == true){
        CollisionResults results = new CollisionResults();
        Ray ray = new Ray();
        Vector2f click2d = inputManager.getCursorPosition();
        Vector3f click3d = cam.getWorldCoordinates(new Vector2f(click2d.getX(), click2d.getY()), 0f);
        Vector3f dir = cam.getWorldCoordinates(new Vector2f(click2d.getX(), click2d.getY()), 1f).subtractLocal(click3d).normalizeLocal();
         ray = new Ray(click3d, dir);
         scene.collideWith(ray, results);
         if(results.size() > 0){
             CollisionResult point = results.getClosestCollision();
            Vector3f destination = point.getContactPoint();

SetModel is running to change the location of the model and rigidbody while PlayerMovingModel is true. and another right click sets the boolean to false, which sets the model at the mouse position which I get from Vector3f destination.

Why you are not using kinematics, or in the case of an tree, mass=0 ?

I don’t know. I haven’t looked that far into rigid body and basically just copied what I use for my player rigid body

I just did a quick Google of kinematic rigid body’s and it sounds like I should be using those for all my nonmoving objects.

An object with mass = 0 can’t be moved around, its static.

I did a quick Google search for “jmonkeyengine rigid mass” and got this as the second hit:


Sets the mass in kilogram. Dynamic objects have masses > 0.0f. Heavy dynamic objects need more force to be moved and light ones move with small amounts of force.
Static immobile objects (walls, floors, including buildings and terrains) must have a mass of zero!

So according to your search I set my mass correctly. I’m going to try to change it to a kinematic body and see if that fixes things.