CapsuleCollision axis

Recently I post http://hub.jmonkeyengine.org/groups/physics/forum/topic/charactercontrol-bouncing/ and I found the problem. My CharacterControl bounced because I was using the CapsuleCollisionShape constructor where I give the axis value (1 = y, in my case) although I don’t understand why it crashes using this constructor. Now, I replaced it using by CapsuleCollisionShape(CapsuleCollisionShape(.55f, 1.7f), .45f); where the default axis value is 1 (1 = y) but here don’t chashes and my CharacterControl works normally.



The problem wasn’t the box shapes or the stepHeight.



I believe the problem is in the constructor of CapsuleCollisionShape because they are different, the constructor without axis parameter don’t call the createShape() method.



Sorry for my English XD, I’m looking forward to your comments

The only difference is that the margin is being set, maybe playing with that solves your problems.

So, why new CapsuleCollisionShape(radius, height, 1) != CapsuleCollisionShape(radius, height)???

Shouldn’t be the same???

Did you notice any changes?

Of course, if you look at the source code of CapsuleCollisionShape, the constructor CapsuleCollisionShape(radius, height) isn’t the same that CapsuleCollisionShape(radius, height, 1), this last constructor constructor calls the createShape() method, the first constructor doesn’t.



I have problems with the second constructor when my CharacterControl walks on the floor made of Boxes, not so with the first constructor.



I guess the cShape.setLocalScaling(Converter.convert(getScale())) and cShape.setMargin(margin) are generating troubles in the createShape() method.



Further, shouldn’t CapsuleCollisionShape(radius, height) be something like this??’



public CapsuleCollisionShape(float radius, float height) {

this(radius, height, 1);

}



Although that would create problems for me…

I know all that, I told you. Now I ask you if setting the margin on the character changes anything.

Not really, XD I solved the problem by changing the constructor since my default value for axis is 1 XD

Can you please test it… -.-

Playing with the margin, values between 0.5f and 0.1f, the behaviour is the same, I could not see differences. Values above 1f, the character gave small/medium jumps.



The default margin value is 0.4f, and when I create a CapsuleCollisionShape(radius, height, 1) calls the setMargin methos with margin value = 0.0. (I guess this is the problem).



Note: this has more influence on the Box shapes that in the Quad Shapes…



Excuse the late response… :slight_smile:

1 Like

normen, would polygons with more triangles be better than the same polygons with less triangles? I am getting confused as I thought this is the problem with bouncing, not the collisionshape. Would appreciate if you summarized it for me :slight_smile:

Thanks @villoto, I need to know how to handle this globally as the margin should be set (also on the “normal” character).

@memonick: In how far do you differentiate polygons and triangles here? They are basically the same in this equation if I’m not mistaken? Anyway the collision is based on the vertices, so just “more vertices” will do it. Which basically means “more triangles” as well as “more polygons” for almost all game meshes I guess…

Thanks normen :slight_smile: So what does this problem regarding axes have to do with bouncing?

Theres a “margin” setting that normally influences when the collision gets first registered by the engine. Apparently it influences bouncing issues in the character too.

I see… thanks.