CollisionShape and BetterCharacterControl

Hi,
I try to change the CollisionShape of BetterCharacterControl
The default one is CapsuleShape but for my player I want a more precise CollisionShape
So I made a MegaCharacterControl extends BetterCharacterControl
who override getShape() methode and replace the CapsuleShape. It works perfectly with BoxCollisionShape but when I try to use CollisionShapeFactory (to fit perfecty my player model) I get this error:

java.lang.IllegalArgumentException
	at com.jme3.scene.Geometry.setMesh(Geometry.java:193)
	at com.jme3.bullet.util.DebugShapeFactory.createDebugShape(DebugShapeFactory.java:116)
	at com.jme3.bullet.util.DebugShapeFactory.getDebugShape(DebugShapeFactory.java:85)
	at com.jme3.bullet.debug.BulletRigidBodyDebugControl.<init>(BulletRigidBodyDebugControl.java:60)
	at com.jme3.bullet.debug.BulletDebugAppState.updateRigidBodies(BulletDebugAppState.java:175)
	at com.jme3.bullet.debug.BulletDebugAppState.update(BulletDebugAppState.java:118)
	at com.jme3.app.state.AppStateManager.update(AppStateManager.java:287)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
	at java.lang.Thread.run(Unknown Source)

I got the same error by using CompoundCollisionShape

Is there a way to make it works or did I need to use an other way to get a precise collision shape ?

my getShape() methode looks like this:

@Override
protected CollisionShape getShape()
{
CollisionShapeFactory collisionshape = CollisionShapeFactory.createMeshShape(playerModel);
CompoundCollisionShape compoundCollisionShape = new CompoundCollisionShape();
Vector3f addLocation = new Vector3f(0.0F, getFinalHeight() / 2.0F, 0.0F);
compoundCollisionShape.addChildShape(collisionshape, addLocation);
return compoundCollisionShape;
}

You really don’t want to do this. There is a good reason for using a spherical shape. A smooth rounded sphere with no extrusions is very unlikely to get caught on any edges.

If the collision mesh is the same shape as your player any sort of flat surface can stick to a wall. Every time you try to pass a corner or run along side another object you will more than likely get stuck.

ok, but how can i need to smooth the edge of my collision shape :neutral_face:
i try too make some sort of shooter game so i need a precise hit box. Maybe it’s not the good way to achieve this.

If you need a hit collision check that doesn’t mean that the physics object to move your character has to be that shape… You might have noticed that in many shooters you can have your hand or weapon “stick inside” a wall but you can still shoot at that hand.

Indeed, i’ll try something else and post it here if it works :slight_smile: