My character cube falling through my maze (both have collision, I see in debug!)

Basically, it falls through maze, and after it passes the y = 0 axis, it gives me an error that I’ll post asap.

Error: [java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]


at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(

at com.bulletphysics.collision.dispatch.CompoundCollisionAlgorithm.destroy(

at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(

at com.bulletphysics.collision.dispatch.CompoundCollisionAlgorithm.destroy(

at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(

at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.cleanOverlappingPair(

at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.removeOverlappingPair(

at com.bulletphysics.collision.broadphase.DbvtBroadphase.collide(

at com.bulletphysics.collision.broadphase.DbvtBroadphase.calculateOverlappingPairs(

at com.bulletphysics.collision.dispatch.CollisionWorld.performDiscreteCollisionDetection(

at com.bulletphysics.dynamics.DiscreteDynamicsWorld.internalSingleStepSimulation(

at com.bulletphysics.dynamics.DiscreteDynamicsWorld.stepSimulation(

at com.jme3.bullet.PhysicsSpace.update(

at com.jme3.bullet.PhysicsSpace.update(

at com.jme3.bullet.BulletAppState.render(



at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(




This is the code pertaining to physics:

[java]bulletAppState = new BulletAppState();


int[] start = (findStart(map.getMapa()));

drawPlayer(start[0], start[1]);

playerShape = new RigidBodyControl(CollisionShapeFactory.createMeshShape((Node) playerNode), 1);


//BoxCollisionShape playerPhy = new BoxCollisionShape(new Vector3f(0.2f, 0.3f, 0.0001f));


playerShape.setGravity(new Vector3f(0, -1, 0));

//playerShape.setPhysicsLocation(new Vector3f(30, 120, 1));

landscapeShape = new RigidBodyControl(CollisionShapeFactory.createMeshShape((Node) sceneMasterNode), 0);


System.out.println(start[0] + " " + start[1]);

//SimplexCollisionShape playerShape = new SimplexCollisionShape // fazer collision melhor




Do you remove objects from the physics space somewhere? This looks like you added or removed an object twice.

The ONLY physics handling ever done is all there.

Went through entire code. Anything physics related, is there.

If it’s relevant:

[java]public void drawPlayer(float xCord, float yCord) {

generationVec = new Vector3f(xCord, yCord, 0.2f);

Box boxShape = new Box(generationVec, 0.2f, 0.3f, 0.001f);

player = new Geometry(“player”, boxShape);


playerImg.setTexture(“ColorMap”, assetManager.loadTexture(“vivi.png”));






this is the Player that sinks

[java]public void makeSquare(int xCord, int yCord, float xSize, float ySize) {

generationVec = new Vector3f(xCord, yCord, 0);

Box boxShape = new Box(generationVec, xSize, ySize, 0.01f);

cube[boxCount] = new Geometry(“terrainSquare”, boxShape);


//floor.setColor(“Color”, ColorRGBA.Blue);

//floor.setTexture(“ColorMap”, assetManager.loadTexture(“Textures/RustFloor.jpg”));

floor.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/RustFloor.jpg”));




public void makeCube(int xCord, int yCord, float xSize, float ySize) {

generationVec = new Vector3f(xCord, yCord, 0.2f);

Box boxShape = new Box(generationVec, xSize, ySize, 0.4f);

cube[boxCount] = new Geometry(“wallSquare”, boxShape);


//wall.setTexture(“ColorMap”, assetManager.loadTexture(“Textures/CaveWall.jpg”));

wall.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/CaveWall.jpg”));




These are the cube and square(floor) drawing methods.

Then one of the nodes (playerNode, sceneMasterNode) don’t give a proper collision shape. What kind of geometry is in the sceneMasterNode? Can you show a screenshot of the whole scene with debug view on?

The sceneMasterNode is a “maze” I start on a top-down view, it has the maze paths, that are a floor, a square with very low Z dimensions, makeSquare, and big cubes that make up the “walls”, makeCube.

There’s only that: those cubes and squares.

Then there’s the drawPlayer, that’s all… Getting a print

Do you generate that mesh yourself as one big mesh? Are you sure all triangles are closed? The static mesh collision shape will only work with proper triangles.

Yes, I used the flycam: I’ll show you give me a sec

Still no luck… no clue what I may be doing wrong, I’ve followed tuts and docs closely though :expressionless:

You know you just put your facebook up on the internet? :stuck_out_tongue:

That ain’t mine, I checked the jpgs and there’s no trace of me hehe

Wouldn’t mind if it had though, never have hidden my identity but don’t exactly go around giving cards either :slight_smile:


playerShape = new RigidBodyControl(CollisionShapeFactory.createMeshShape((Node) playerNode), 1);

replaced by

playerShape = new RigidBodyControl(CollisionShapeFactory.createDynamicMeshShape((Node) playerNode), 1);

I can get SOME collision but it’s very buggy, the character will land on maze, and then sink through it very slowly, and suddenly disappear and warp off somewhere

Just create a proper mesh instead of stacking boxes like this or if you have to stack boxes, use box collision shapes instead of using the recursive mesh generation.

Sorry I couldn’t quite understand you…

The map is generated by having an algorithm I made on a side-class make me a int[][] field with values for what will be a wall, a void, or a square(the paths), so it places a cube/square for each value on the int[][] array. How can I do it any differently?

What is “a proper mesh”? What did I do of recursive? I don’t understand really >.>

This is how the map is drawn, using the methods makeCube and makeSquare I showed before:

[java]public void drawMap(int[][] mapa) {

int mapaX = mapa.length;

int mapaY = mapa[0].length;

for (int i = 0; i < mapaX; i++) {

for (int a = 0; a < mapaY; a++) {

if (mapa[a] == 1) {

makeSquare(i, a, 0.5f, 0.5f);

} else if (mapa[a] == 2) {

makeCube(i, a, 0.5f, 0.5f);





you create separate geometries, instead you should create one mesh for the whole maze.

Not quite sure how I’d do that, any tips?

Read the dynamic mesh tutorials and read up on voxel worlds. Essentially you are creating a variant on a box world.

1 Like

did you try to convert everything into 1 node with GeometryBatchFactory.optimize ?