Noob Question - CompoundCollisionShape , how?

Im trying to create a super simple collision shape basically just two boxes one trailing after the other. The problem is that when i connect the boxes to the physics only one of them follow the physical body. Im guessing that a RigidBodyControl only can control one spatial?

Anyways here is parts of my code:

    CompoundCollisionShape ccs = new CompoundCollisionShape();
    

        BoxCollisionShape box = new BoxCollisionShape(new Vector3f(0.5f, 0.5f, 0.5f));
        ccs.addChildShape(box, new Vector3f(0,0,0));
        ccs.addChildShape(box, new Vector3f(0,0,1));


        RigidBodyControl rbc = new RigidBodyControl(ccs,4f);


geo1.addControl(rbc);
geo2.addControl(rbc);

phys.getPhysicsSpace().add(rbc);

Well either make them to one mesh, via geometry batching, or use a compound collision shape.

ALL controls can only be on one spatial at a time. It’s not even really logical to put them on more than one as they would get the exact same position in this case… and if that’s what you want then put them as child to a node that gets the control.

What i want is for multiple spatials to follow a single physics object. My thought is that the physicsal object (cube or such) will act much as a hitbox while the other spatials will be the arms, legs etc. But for this to happen i want them to always follow the physical object. I could just put a setLocalTranslation in the update loop but i thought that there was a better way to accomplish this.

I created a simple scetch of what im trying to accomplish.scetch

I’d say:

  • make a collision shape for the body or whatever form you want to check for collisions
  • attach the body and the other parts to a node
  • have a controller control that node for movement/rotations
@c.r.raschke said: What i want is for multiple spatials to follow a single physics object. My thought is that the physicsal object (cube or such) will act much as a hitbox while the other spatials will be the arms, legs etc. But for this to happen i want them to always follow the physical object. I could just put a setLocalTranslation in the update loop but i thought that there was a better way to accomplish this.

I created a simple scetch of what im trying to accomplish.scetch

@pspeed said: ALL controls can only be on one spatial at a time. It's not even really logical to put them on more than one as they would get the exact same position in this case... and if that's what you want then put them as child to a node that gets the control.

Note: where I talk about making a node and attaching things as children.

If using a scene graph is new to you then I highly recommend reading one of the help docs: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies