Collision shape of animated model

hi :wink: i am working with animated model but i don’t understand what is best way for manage mesh collision.

what kind of Collision shape i have to use?

i red this https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:physics that explain differences between collision shape but i don’t find in this how to make mesh collision.



i have understand that for manage a model i have to use CharacterControl and attach it to a collision shape.

but which collision shape?



thanks a lot :wink:

Hello!



For most applications of the CharacterControl, I would suggest using a sphere collision shape or a capsule collision shape. It is normally not a good idea to use the actual mesh’s shape for collision unless you absolutely need that kind of granularity. That usually leads into a bunch of other problems as well, so I’d stick with spheres or capsules.



Cheers!

~FlaH

ok i used capsule but i have another problem.

for check that all was ok i have set physic space in debug mode : bulletAppState.getPhysicSpace().enableDebug(assetManager);



after that i seen that my model is not all inside a capsulecollisionshape but a part of its body is inside and another part is outside.

It is 1 hours that i try to fix this problem but nothing.

have you alredy seen a problem of this kind?



code for manage my model :



[java]

Node player = (Node)asset.loadModel(path);

control = player.getControl(AnimControl.class);

control.addListener(this);

channel = control.createChannel();

channel.setAnim(startAnimation.toString());



CapsuleCollisionShape shape = new CapsuleCollisionShape(1f, localScale, 1); //localScale is scale of model

CharacterControl characterControl = new CharacterControl(shape, 0.1f);



player.setLocalScale(localScale);

player.addControl(characterControl);



rootNode.attachChild(player);



bulletAppState.getPhysicsSpace().add(characterControl);[/java]

Hello again!



Yeah, just make the capsule as big as you need it to be. If you make a capsule as you are, the radius is 1 unit, and the shaft is whatever you have that localScale set to, let’s say 3 for example. This means the whole capsule is 5 units tall. This is due to the radius on both ends so keep this in mind. In your setup there, it would be 2 (1 + 1 radius), plus whatever localScale is equal to. One thing to keep in mind is that in most game applications the entire model is not within the collision boundaries. There are plenty of first person and third person games where you can visibly see the character’s arms (for example) going into world geometries. So I wouldn’t worry about it too much. I’d say as long as you can get the major body parts in the capsule you’ll be fine (legs, torso and head. Arms are the debatable parts).



~FlaH

ok that is true :wink: but also changing size of model and capsule (i made different test) ,capsule touch terrain ma my model

start always from the half of capsule (my model doesn’t touch terrain :frowning: )

Hello again!



Simple. Either make the capsule the same height as your model, or add the characterControl to a node, and then attach your model to that node and adjust it’s position accordingly.



~FlaH

tehflah said:
Hello again!

Simple. Either make the capsule the same height as your model, or add the characterControl to a node, and then attach your model to that node and adjust it's position accordingly.

~FlaH


the capsule use the model center to determine position inside the capsule either place your model center in the absolute middle on of your model or devise and offset vector to do it in game............your model most be centered at its feet.

thanks monkeys :wink: i don’t understand how change center directly from code. i try to modify center by using blender. :wink: