PhysicsCharacterNode acting like ghost

Hi Guys,



I am currently working with JME and JME-Bullet, and i got some issues with a PhysicsCharacterNode.



It’s acting like ghosts sometimes, it’s going through different obstacles.



Some screenshots to illustrate the problem :



a good collision between the character (sphere) and the environnement (a 3DSMax mesh) :







and a bad collision :





(in this case, the sphere just disappear under the terrain)



I need some help on this case :). Got some ideas ?



Thanks for your answers.



PS : Here is the code for the terrain and the character creation





//Terrain
        Node terrainNode = mMeshLoader.loadMeshModel("/divers/terrain2", "terrain");
        terrainNode.updateGeometricState(0, true);
        PhysicsNode terrainPhysicsNode = new PhysicsNode(terrainNode, new MeshCollisionShape(terrainNode), 0f);
        terrainPhysicsNode.setLocalTranslation(new Vector3f(0f, -100f, 0f));
        rootNode.attachChild(terrainPhysicsNode);
        terrainPhysicsNode.updateRenderState();
        pSpace.add(terrainPhysicsNode);
      


//character
        Sphere caps=new Sphere("character",8,8,2f);
        character=new PhysicsCharacterNode(caps, CollisionShape.ShapeTypes.SPHERE, 0.1f);
        character.setLocalTranslation(0f,20f,0f);
        rootNode.attachChild(character);
        character.updateRenderState();
        pSpace.add(character);



You cannot load a Node and create a MeshCollisionShape from it, only the first child mesh in the node will be used for the collisionshape. You will have to create a CompoundCollisionShape, create MeshCollisionShapes for all mesh children of the node and add them to the CompoundCollisionShape at the correct locations.



Hope this helps,

Normen

Hi Normen, thanks for the quick answer :).



But the terrain is composed by a unique mesh. I had the same issue with a simpler terrain (still a one-mesh terrain).



A screen :







Maybe a too stiff slope ?

Can you try creating all collision shapes not with the ShapeType.XXX constructor but before? Maybe something ugly happens there. Did you try the debug view lately added to svn? Just to check if jme shows what the physics do :slight_smile:

Anyway it could very well be that the character node in bullet sinks into the mesh at steep slopes, it could also be that the sphere is too small (0.1m) for a correct computation.

Hmmm i will take a look at this stuff. But i need some sleep before :D.



Thanks for this ideas.

Ever find a solution to this?  I'm seeing the same thing with a terrain block and a PhysicsCharacterNode.  When it comes to a slope it starts to sink right through the world.  :/



The behavior acts differently when you adjust the StepHeight variable so it seems like it is related to it somehow… low it will fall through the TerrainBlock even on relatively flat surface, set it high, and it will walk up slopes which I guess is better than falling through the World, but still isn't right.

sb81 said:

Ever find a solution to this?  I'm seeing the same thing with a terrain block and a PhysicsCharacterNode.  When it comes to a slope it starts to sink right through the world.  :/

The behavior acts differently when you adjust the StepHeight variable so it seems like it is related to it somehow... low it will fall through the TerrainBlock even on relatively flat surface, set it high, and it will walk up slopes which I guess is better than falling through the World, but still isn't right.

Jme 2 or 3? did you try enabling the debugs shapes to see where your physics objects really are?

JME2 - also I was looking for the attachDebug function but could not find it in my build of jbullet-jme and I rebuilt via http://jbullet-jme.googlecode.com/svn/trunk/ last night.  Wasn't sure if that was a JME3 feature only.



Thank you as always Norman!  You are a true asset to humanity! (To the part of humanity who wishes to program games in Java anyways.  :D)

sb81 said:

Thank you as always Norman!  You are a true asset to humanity!


Who's Norman? XD  This is gonna become a jME-meme :P

Not if I can help it! Evil laugh  }:-@

The word-you-know-you-cant-say is now being replaced with the proper. No meme will formulate!

sb81 said:

JME2 - also I was looking for the attachDebug function but could not find it in my build of jbullet-jme and I rebuilt via http://jbullet-jme.googlecode.com/svn/trunk/ last night.  Wasn't sure if that was a JME3 feature only.

Thank you as always normen!  You are a true asset to humanity! (To the part of humanity who wishes to program games in Java anyways.  :D)

Well thank you :) Debug is implemented differently in jme2, it was written by somebody else and depends more on jbullet classes and calls, thats why I implemented it differently in jme3 (to make the switch to native easier). Theres an example class for it included in the jbullet-jme source I think.

For bullet-debugging in jme2 you can change your render-method like this:


   
@Override
public void render(float tpf) {
       super.render(tpf);
       PhysicsDebugger.drawWireframes( DisplaySystem.getDisplaySystem().getRenderer() );
}

Thank you very much ttrocha, I have added the debug frame and have taken a screen shot.



The green frames is a square with a Sphere PhysicsCharacterNode collision shape falling through the side of the hill.



The bottom of the terrain is green, so hopefully you guys will see this screenshot and tell me something silly like I need to flip the terrain's normals or something.  :slight_smile:

Btw, have you tried, if a normal physicnode falls through the terrain at that place too?

I have only seen a regular physics node fall through the terrain once while I was playing around with it, but it was when I applied a continuous force to it and it was going really fast.



I also set the x and z linear velocity to something like 5f and set y to getLinearVelocity.y so it was moving along with the terrain and it would go up and down the terrain.



While it's occuring, it looks like the PhysicsCharacterNode is jittering a little as it's fighting to get up the slope and works it's way through the terrain.  It doesn't appear to happen if the slope is passable.

Sounds kinda like there is a bug in the jbullet core to me…