[SOLVED] Sticky CharacterControl collision

My CharacterControl is moving across a smooth surface with no bumps or niches. For some reason, I can only move a few inches before stopping as if hitting an object. I have to jump over whatever it is. It moves just fine in the air.

My Code
private final float jumpVel = 20, fallForce = 30, mass = 70f, height = 10;
CapsuleCollisionShape capsule = new CapsuleCollisionShape(1f, height);
private CharacterControl guy;
Geometry body;
private final Node guyNode = new Node("player node");
...
protected void build(AssetManager manager) {
	guy = new CharacterControl(capsule, 0);
	guy.setJumpSpeed(jumpVel);
	guy.setFallSpeed(fallForce);
	guy.setPhysicsLocation(pos);
	guy.setGravity(new Vector3f(0, -20, 0));
	body = new Geometry("body", new Box(1, height*0.5f, 1));
	body.setLocalTranslation(pos);
	Material mat = new Material(manager, "Common/MatDefs/Light/Lighting.j3md");
	mat.setBoolean("UseMaterialColors", true);
	mat.setColor("Diffuse", ColorRGBA.Blue);
	body.setMaterial(mat);
	body.addControl(guy);
	guyNode.attachChild(body);
}
...
protected void move(Camera cam) {
	Vector3f camDir = cam.getDirection().multLocal(0.5f);
	Vector3f camLeft = cam.getLeft().multLocal(0.2f);
	Vector3f walkDirect = new Vector3f(0, 0, 0);
	if (up) walkDirect.addLocal(camDir.x, 0, camDir.z);
	if (down) walkDirect.addLocal(-camDir.x, 0, -camDir.z);
	if (left) walkDirect.addLocal(camLeft);
	if (right) walkDirect.addLocal(camLeft.negate());
	guy.setWalkDirection(walkDirect);
}

The collision box for the player doesn’t seem to go into the ground anyway (hard to tell tho). :confused:

I was having several problems like that with CapsuleCollisionShape , one of them was the object being flipped & rolled inside the capsule enclosure as if i were doing experiments on a hamster ,LOL,

i think that basically happens if you have a radius below a particular offset or the height is larger than radius.

try BoxCollisionShape for box or tall objects , use CollisionShapeFactory.createBoxShape(shape:Spatial); for regular box shape. & try this if you need full collision mesh CollisionShapeFactory.createDynamicMeshShape(shape:Spatial) but its cpu intense & very accurate .

Check CollisionShapeFactory class :

https://javadoc.jmonkeyengine.org/v3.3.2-stable/index.html

1 Like

if its normal Character control adjust the step size, BCC also suffers this but there is no step size adjustment for that

In case you haven’t solved this issue yet, I suggest comparing your app with one of the jme3-examples apps that use CharacterControl:

If those apps work for you, focus on what your app does differently.

I’m still having the problem.

I tried running those examples, all of them have some these strange bugs for me.

  • HelloCollision was stopped with a null pointer exception (probably due to missing assets).
  • HelloTerrainCollision had the gravity flipped so I had to constantly jump in order to stay down.
  • TestPhysicsCharacter had the gravity flipped sideways.
  • TestWalkingCharacter also had the same problem.
  • TestBetterCharacter was better, but it still had sticky collisions on the side of blocks.

It almost seems that the default gravity direction is sideways, because when I do not specifically set gravity for my CharacterControl, I end up falling sideways.

Maybe CharacterControl is just messed up for me?

1 Like

The sideways gravity symptoms you describe match issue 910, which affects jme3-bullet in v3.2. Please upgrade to JME v3.3 and/or use Minie or jme3-jbullet.

By the way, TestBetterCharacter doesn’t actually use CharacterControl.

1 Like

What is it? I can’t find it in the docs.

1 Like

jme3-jbullet is a physics library included in JMonkeyEngine that’s compatible with jme3-bullet, only written entirely in Java. (jme3-bullet uses JMI to access C++ code.)