Problem with reponding to physicscollisionevent

I am facing problems while responding to a PhysicsCollisionEvent.



My PhysicsCharacteNode is walking towards a pick-able item, and I want him to pick it(disappearance of the object) when he collides with it.



physicsCharacterNode code is following which is in the simpleInitApp()

[java] geo_player = assetManager.loadModel("Models/rabbit/rabbit.j3o");

geo_player.setLocalScale(0.25f);

geo_player.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.PI , new Vector3f(0,1,0)));

geo_player.setShadowMode(ShadowMode.CastAndReceive);

pn_player = new PhysicsCharacterNode(new CapsuleCollisionShape(1.7f,3.8f), 0.05f);

pn_player.attachChild(geo_player);

pn_player.setGravity(17);

pn_player.setFallSpeed(17);

pn_player.setJumpSpeed(10);

pn_player.setLocalTranslation(0,35,8); [/java]



[java] geo_dice = assetManager.loadModel("Models/items/dice.j3o");

Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/SolidColor.j3md");

mat.setColor("m_Color", ColorRGBA.Yellow);

mat.setColor("m_GlowColor", ColorRGBA.Blue);

geo_dice.setMaterial(mat);

BoxCollisionShape cs_dice = new BoxCollisionShape(new Vector3f(1f,2f,3f));

pn_dice = new PhysicsNode(geo_dice, new BoxCollisionShape(new Vector3f(1f,2f,3f)), 1.5f);

pn_dice.setLocalTranslation(0, 300, 0);

pn_dice.attachDebugShape(assetManager);

rootNode.attachChild(pn_dice);

bulletAppState.getPhysicsSpace().add(pn_dice);



bulletAppState.getPhysicsSpace().addCollisionListener(this);[/java]



& trying to print out names of nodeA and nodeB

[java] public void collision(PhysicsCollisionEvent event) {

reportGUIText.setText("a is " + event.getNodeA().getName() + " b is " + event.getNodeB().getName());

}[/java]



But, they are printing null.



Where could be the problem?



i tried with a SphereCollisionShape being thrown at the BoxCollisionShape & physicsCharacterNode, and the collision event pick up the sphere, but, others are not collected by another node.



the player and dice is on a MeshCompoundShape



[java] Spatial geo_basicPlatform = assetManager.loadModel("Models/scene/world.j3o");

geo_basicPlatform.setLocalScale(0.25f);

geo_basicPlatform.setShadowMode(ShadowMode.CastAndReceive);

CompoundCollisionShape cs_basicPlatform = CollisionShapeFactory.createMeshCompoundShape((Node)geo_basicPlatform);

pn_basicPlatform = new PhysicsNode(cs_basicPlatform, 0f);

pn_basicPlatform.attachChild((Node)geo_basicPlatform);

pn_basicPlatform.setLocalTranslation(new Vector3f(0,-0.25f,0));

bulletAppState.getPhysicsSpace().add(pn_basicPlatform);

rootNode.attachChild(pn_basicPlatform);[/java]

Probably you didnt give them a name.

:frowning: this was embarrassing .



thanks. It wasn’t mentioned anywhere, i thought, it was gonna pick the underlying geometry name, like a ray does.

there is also somthing weird, if i use boxCollisionShape then the rabbit have to stand on the box to detect it.Just touching dont work.



But, this problem is gone if i use createBoxCompoundShape.Just getting touched, detects it.



what is it that im missing?