Collision Information

How I am going to extract all the collision information(name), when simultaneously several collisions are happening?

Like X is standing on Ground, and Y is also standing on ground.

I find (in collision(PhysicsCollisionEvent event) )that nodeA is ground and nodeB is Y, but i want to check collision of A with another object.

Can anyone tell me how to get a particular collision when more then one is happening at the same time?

Several physicsCharacterControl is on the ground and collision(PhysicsCollisionEvent event) is only detecting all collisions of, only one of them.

tried with following

[java]public class Main extends SimpleApplication implements PhysicsCollisionListener {

public void simpleInitApp() {

bulletAppState = new BulletAppState();




public void collision(PhysicsCollisionEvent event) {


what exactly i need to write differently?

You write nothing differently, just check if objectA or objectB is the object you want to check.

ok, i am going with some details.

here, the dice is a pickable object, and in the collision method I am checking if nodeA = rabbit and nodeB = dice(and vice versa), then rabbit picks the dice.

But, the problem is when rabbit collides with the dice, at the same time, rabbit is also colliding with the ground mesh(where it is standing), so, i cannt get the feedback of rabbit colliding with the dice.As a result, i cant pick the dice.

So, how can i approach this problem?

No, when the rabbit collides with the crystal there should be at least one PhysicsCollisionEvent with those two nodes in it. Are you sure you read all data in the collision() method? The collisionEvent is cleared when that method finishes.

No, I am just using a GUI Text to check whether I am getting the collision feedback. But, while the rabbit is on the ground, I never get the collisoin feedback with the crystal.

public void collision(PhysicsCollisionEvent event) {

reportGUIText.setText(“A” + event.getNodeA().getName() + " B " + event.getNodeB().getName());


in the PhysicsCollisionEvent ‘event’, all the methods are related to Object_property_A & Object_property_B. How do i read/check all the collisions happening at-the-same-time?

Some example code would be very helpful.

They don’t happen at the same time, they always happen sequentially and are also sequentially reported.

Edit: I guess the other collision is only reported shortly and you don’t see it on screen because the other collision overwrite the result. In code you can filter it out by checking for the objects or Spatials.

oh, my bad. Thanks. I got it.

But, when I will have a complicated level with a lots of physics object moving and colliding with each other, then isn’t it going to be a huge if-elseif mess? Do you plane to make any other work around of this system?

Anything would be a “mess” like that. Even when its hidden in an api :wink: You can implement any way you like yourself, e.g. a list with “ObjectTypeListeners” that you create yourself that have a collision() method and an getObjectType() method that gets looped through on the “real” collide method and filters it before, then you just have to add your own ObjectTypeListeners to this list.

Things are good, but, the get-collided-then-pick isn’t working smoothly. I have to push the crystal to grab. :frowning:

I have a weird feeling that this direct collision system may be good for flying bomb but not for picking up object.

So, what can I do to solve this issue?

I have been thinking about PhysicsGhostControl. Well, what is it for actually?

I tried with the following code, but, sill that lagging problem remains

dice1_node = (Node)assetManager.loadModel(“Models/items/dice.j3o”);




CollisionShape dice1_cs = CollisionShapeFactory.createDynamicMeshShape(dice1_node);

dice1_control = new PhysicsGhostControl(dice1_cs);


dice1_control.setPhysicsLocation(new Vector3f(-1.37f, -14.06f, 222.87f));



In the examples, things are not different from this code, but, why my character is still colliding with the crystal?

I don’t understand what “push the crystal to grab” means? Also what do you mean by “direct collision system”? You run into the crystal, then you call whatever is necessary to make it disappear and add a point to the players pointlist. You can also use the Spatial.getUserData() to identify the objects and/or set if it has been collected already, how many points it is etc. The GhostObject (you can also use the base class) is for checking which physics objects overlap at that location, theres a test class for it.

I meant the crystal is acting as an obstacle for the player, it just dont disappear(detaching from node and bulletApp) when I touch it. I have to consciously push it to take it. In the video you will see when i touch it, nothing happens, but, when i try another time, then it works.But, it shouldn’t be in this way, should it?

Here is a video showing the issue

(video isnt showing up properly)

Mabye you want to try ray checks when the user presses a button or something?

Ray checks can be good to pick/check when object should be placed on a certain direction with respect to the player. Like I have to face towards a button to activate it, just getting near wont work.

But how they are going to help me here? when coming for any direction should pick up the object(like moving backward while, facing forward,to pick the crystal)

Is this lag an issue? I dont understand by what do you mean by “presses a button”.

I mean that you could do a ray check in he forward direction when the user presses a button and pick up everything it hits. Anyway I dont know why your program fails with this, I changed the TestPhysicsCharacter a bit and it worked fine for me.

Here, answering to your PM, I added the following to TestPhysicsCharacter to simulate picking up stuff and it works fine:


//simpleInitApp, line 101


//simpleInitApp, line 107

physicsCharacter.setUserData("player", true);

physicsBox.setUserData("collectable", true);

//TestPhysicsCharacter implements PhysicsCollisionListener

public void collision(PhysicsCollisionEvent event) {

if (event.getNodeA().getUserData("collectable") == Boolean.TRUE

&& event.getNodeB().getUserData("player") == Boolean.TRUE) {

event.getNodeA().setUserData("collectable", false);



} else if (event.getNodeB().getUserData("collectable") == Boolean.TRUE

&& event.getNodeA().getUserData("player") == Boolean.TRUE) {

event.getNodeB().setUserData("collectable", false);








Dude, this one seems a little more slower then the brute force checking. :frowning:

I am pretty sure, something is going wrong here, Can you please check it with those assets?

You didn’t send me anything. And the collisions work fine.

:frowning: ops, i missed the linked.