Collision Problems

Hello all. I’m having some collision problems. I have a scene with a level mesh and a character, and I’m trying to get collision outputs with the collision() method. However, it’s not registering anything. In fact, in the output panel (at the end of initialization) it reads, “warning CollisionDispatcher.needsCollision: static-static collision!” I’m not quite sure what this wants me to do… As far as I know, I don’t have any DYNAMIC collision controllers. Anyways, here’s my set-up code:





The level set-up (no it’s not actually terrain, I just copy and modify code ^^ lol)

[java]

private void createTerrain() {



terrain = (Node) assetManager.loadModel(“Scenes/mapandclimbmeshh.j3o”);

terrain.setLocalTranslation(new Vector3f(-150,0,0));

terrain.setLocalRotation(PITCH090);

terrain.scale(2);

terrainPhysicsNode = new RigidBodyControl(CollisionShapeFactory.createMeshShape(terrain), 0);

terrain.addControl(terrainPhysicsNode);



terrain.setShadowMode(ShadowMode.CastAndReceive);

rootNode.attachChild(terrain);

getPhysicsSpace().add(terrainPhysicsNode);

}[/java]



The character set-up

[java] private void createCharacter() {

SphereCollisionShape sphere = new SphereCollisionShape(4f);

ghosty = new GhostControl(sphere);





CapsuleCollisionShape capsule = new CapsuleCollisionShape(3f, 4f);

character = new CharacterControl(capsule, 1f);

model = (Node) assetManager.loadModel(“Models/Sinbad/SinbadNew/Edit/Sinbad.mesh.xml”);

model.setName(“char”);

//model.setLocalScale(0.5f);

model.addControl(character);

model.addControl(ghosty);

model.setShadowMode(ShadowMode.CastAndReceive);

character.setPhysicsLocation(new Vector3f(-150, 65, -10));

character.setJumpSpeed(20);

rootNode.attachChild(model);

getPhysicsSpace().add(character);

getPhysicsSpace().add(ghosty);

} [/java]



So, what do you guys think the problem is? Thanks.





-NomNom

did you remember to register the collisionListener?



[java]getPhysicsSpace().addCollisionListener(myCollisionListener);[/java]

1 Like

After much experimenting and checking, I realized that I did in fact need the getPhysicsSpace().addCollisionListener(this); ha ha thanks ^^ Now I can FINALLY move on…



-NomNom