Dynamically Updated Mesh CollisionShape?

How can I dynamically update the collision shape of the character im using, for example the ninja.mesh.xml ? I found that for instance the Ferrari car does this in TestFancyCar.onAction method like this:

player.setCollisionShape(CollisionShapeFactory.createDynamicMeshShape(findGeom(carNode, "Car")));

How would that work for the Ninja model?
I already found a way to show the bone structure, like this:

SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", animationControl.getSkeleton());
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");

but can’t seem to figure out how to update the collision shape and show the wireframe for the model itself while walking, jumping etc…

Im using this to update the mesh shape

CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Spatial) modelNode);
RigidBodyControl mesh = new RigidBodyControl(sceneShape, 0.1f);

However this shows a static model collision shape,


Did you try testing the collision shape itself? Maybe the wireframe doesn’t get updated for some reason.

Use CapsuleCollisionShape and CharacterControl:

CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(x,z,k);
character=new CharacterControl(capsuleShape, k);

RigidBodyControl and CollisionShape are used more for terrain, spatial, and very large geometrical standards. If this is just for a ninja model use capsule and charactercontrol.

Yeah I tried testing the collisionshape, it’s actually visible, but remains static and doesn’t follow the player’s mesh as it moves and animates.

That doesnt seem to work, now I just see a capsule around the ninja,
I want to see the current mesh shape of the collisionshape as the model moves and animates.

Here is what I have now:

As you can see, the collisionshape is not the same as the shape of the player or ninja

Check out the RagDoll examples, like the one with the Ogre and the Wall.


Have you disabled hardware skinning?

1 Like

no It still doesnt work
what do you do all day?
Create red and blue cubes and make them rotate?

Pft, red and blue cubes are so 2017. I only work with state-of-the-art red and blue spheres.