Collision detection problem with BetterCharacterControl

After recently discovering JMonkey Engine, and falling in love with it, I decided to ditch my engine, and attempt to utilize the JMonkey Engine. After tampering aryound with the Hello Collision Detection, I decided to attempt to rewrite Hello Collision Detection to fit my needs. I created a class (named Player) which can move the player, and can obtain the location of the player, among other things. Thankfully, I managed to get the camera and the new player class hooked up. Unforently, however, I managed to break my collisions :(. I believe that this error is in the SimpleAppInit() so I included that function definition. After spending an hour or two on fixing it, I decided to post it on the forums.
Thanks in advance!

public void simpleInitApp() {
bulletAppState = new BulletAppState();
viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f));
float radius = 0.5f; //meters
float height = 1.62f; //meters
float mass = 70f; //kilograms
playerController=new BetterCharacterControl(radius, height, mass);
Spatial level = assetManager.loadModel(“Models/Test.j3o”);
com.jme3.bullet.collision.shapes.CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) level);
landscape = new RigidBodyControl(sceneShape, 0);
keyboard = new KeyboardManager(inputManager);
player = new Player(playerController, rootNode);
player.move(new Vector3f(0, 10, 0));

i don’t know what you mean by “break the collision”. Do you fall through ground ? Are you stuck in the ground ?

And i don’t know what your “move” function (in line 19 in this piece of code) do, but if it’s only a “setLocalTranslation” it’s not gonna work. Also, we don’t know how you bind the bettercharactercontrol with the node, so it will be hard to help you.

But as long as you don’t explai what you mean by “break the collision” we can’t help.

I found only one thing that break the bullet engine and create weird results : if you add an item with a position with some infinite in it or if you put an object with a NaN position. This later seems to break other items, which is a pretty strange behaviour.

And if you don’t know the javadoc very well (actually the IEEE-754 doc), you can do all the “position.x == Float.NaN” you want, the “==” always return false for NaN. Yep, Float.NaN == Float.NaN return false.

But i don’t think that you are in this case.

Thanks for the response!
Sorry for the vaugeness, What I meant IS that I fall through the floor

Well either the player class or the move method is responsible, could you show those?

of Course!
public class Player {
BetterCharacterControl characterControl;
Node playerNode;
public Player(BetterCharacterControl characterControl, Node rootNode) {
playerNode = new Node(“Player Node”);
public Vector3f getLocation(){
return playerNode.getWorldTranslation();
public void move(Vector3f newPos){
Thanks in advance!

I’m also pretty new with this stuff, but have you tried


Is the character control literally just appearing above the level, and falling directly through it?

:facepalm: 1000x over … collision detection was working, the camera was working, the problem was that the camera was positioned at the players feet and not the players head… so the camera clipped through the floor.

Thankfully, I managed to get the camera and the new player class hooked up. Unforently, however, I managed to break my collisions
Sorry for the vaugeness, What I meant IS that I fall through the floor
1000x over

I think you mean the first time. If the camera is positioned at the players feet as you have said, then it isn’t falling as previously suggested, which is why I made the assumption the character control’s collision shape was falling. Plus the flycam does not collide with anything as it has no physics objects. I apologize for being so stupid.

[java]player.move(new Vector3f(0, 10, 0));[/java] here you warp the player 10 up. You never do the same with the camera, so no wonder it is positioned at it’s feet.

:facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm: :facepalm:

it as close to nothing to do with this topic but i want to point something : in the same way that there is no “automatic” link between the camera and the charactercontrol (or the bettercharactercontrol), there is no link between the camera’s position and the “ear” for the sound. I think that later you’ll want to add spatialized sound (with a source etc.) and this little thing drove me crazy in the past.
You’ll have to add yourself an ear and make sure that this ear follow the camera, or you’ll come here again to say “omg, spatialized sounds don’t work” ^^.

:slight_smile: Someone should put together some tutorials on these things…


well, the only thing that is missing is a blinking red text with a font in 400% size. and i also didn’t found if the doppler effect if calculated automatically with the movement of the origin or if i have to set it myself. You see, things like this.