setMaxSlope for BetterCharacterControl

I switched to BetterCharacterControl and my main character gets this problem. It slides and goes to a complete halt when facing a slope or a minor obstacles. How can I prevent the sliding and stopping when the ground is uneven? I read that there was something like setMaxSlope for CharacterControl, is there something like it also for BetterCharacterControl and is it that method that I should be using?

The code that creates my main character is

[java]private void createNinja() {
ninjaNode = (Node) assetManager
.loadModel(“Models/Ninja/Ninja.mesh.xml”);
ninjaNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
ninjaNode.setLocalScale(0.06f);
ninjaNode.setLocalTranslation(new Vector3f(55, 3.3f, -60));
ninjaControl = new BetterCharacterControl(2, 4, 0.5f);
ninjaControl.setJumpForce(new Vector3f(6, 6, 6));
ninjaNode.addControl(ninjaControl);
rootNode.attachChild(ninjaNode);
bulletAppState.getPhysicsSpace().add(ninjaControl);
getPhysicsSpace().add(ninjaControl);
animationControl = ninjaNode.getControl(AnimControl.class);
animationChannel = animationControl.createChannel();
}[/java]

That code is inside the createcharacters method that gets called my the initialization of the app:

[java] private void createCharacters() {

	createNinja();
	createGoblin();
	createJamie();
	createOto();
	createMonster();

}

@Override
public void simpleInitApp() {
	this.setDisplayStatView(false);
	bulletAppState = new BulletAppState();
	bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
	stateManager.attach(bulletAppState);
	bulletAppState.setDebugEnabled(false);
	setupKeys();
	DirectionalLight dl = new DirectionalLight();
	dl.setColor(ColorRGBA.White.clone().multLocal(2));
	dl.setDirection(new Vector3f(-1, -1, -1).normalize());
	rootNode.addLight(dl);
	AmbientLight am = new AmbientLight();
	am.setColor(ColorRGBA.White.mult(2));
	rootNode.addLight(am);

	if (useHttp) {
		assetManager
				.registerLocator(
						"http://jmonkeyengine.googlecode.com/files/quake3level.zip",
						HttpZipLocator.class);
	} else {
		assetManager.registerLocator("quake3level.zip", ZipLocator.class);
	}

	// create the geometry and attach it
	MaterialList matList = (MaterialList) assetManager
			.loadAsset("Scene.material");
	OgreMeshKey key = new OgreMeshKey("main.meshxml", matList);
	gameLevel = (Node) assetManager.loadAsset(key);
	gameLevel.setLocalScale(0.1f);
	gameLevel.addControl(new RigidBodyControl(0));
	getPhysicsSpace().addAll(gameLevel);
	rootNode.attachChild(gameLevel);
	getPhysicsSpace().addAll(gameLevel);
	createCharacters();
	setupAnimationController();
	setupChaseCamera();
	setupFilter();
}[/java]

How should I resolve my issue?

1 Like

[video]http://youtu.be/PF_UzoOXD0E[/video]
Above is with the CharacterControl
[video] http://youtu.be/P1tmW0JKAqA[/video]
And this second video is with the BetterCharacterControl.

Bump for more info, what are we supposed to do to make the character move smoothly over stairs and slopes with the BetterCharacterControl?

I also think i have this problem… and I think phr00t’s game 3089 has this problem, I’m guessing he uses bettercharactercontrol too.

1 Like

I’m all ears, the BetterCharacter class is much easier to change or extend than the old CharacterControl so hit me when you have a solution.

1 Like

I’m trying to extend it in to add the functionality.

[java]import com.jme3.math.Vector3f;
import com.jme3.bullet.control.BetterCharacterControl;

public class GameCharControl extends BetterCharacterControl {
protected Vector3f lastlocation = new Vector3f();

public GameCharControl(float x, float y, float z) {
	super(x, y, z);
}

@Override
public void update(float tpf) {
	super.update(tpf);
	if (location.equals(lastlocation)) {
		//What to do here?
	}
	rigidBody.getPhysicsLocation(location);
	applyPhysicsTransform(location, rotation);
	lastlocation = location;
}

}
[/java]
If the character doesn’t move then we can change height percentage, manipulate gravity or if you might comment on how to proceed?.