Collision event called before actual collision?

I have a PhysicsCollisionListener that changes the color of a spatial it collides with. This works fine. The problem is that the “collision(PhysicsCollisionEvent event)” method is called before the rigidbody actually contacts it, which means that this function is sometimes called, but still misses the object resulting in a falsely reported collision. Is the the normal behavior of the collision listener or am i doing something wrong?

What do you mean by “actually”? For bullet it “actually” contacts if when the event is spawned. The display is basically one frame late (as in most physics implementations), yes.

I mean the collision method is called even when the rigid body does not touch it:

http://i.imgur.com/0LZaA.png





In this case the CollisionSphere passed right by the box, and it still turns blue (i.e. the collision event was called). As you can see in the background the initial state of the boxes is gray.

Do you move any rigidbodies with mass=0 that are not kinematic?

No

Can you make a test case of this?

I think I have bigger problems here. When I increase the size of a ghost a have attached to the spatial, it calls the collide method for the rigid body… am I not supposed to have a rigidbodycontrol and a ghost contorl attached to the same node?

Well you can but you get the mentioned effect :slight_smile: You can avoid it with collision groups or a collision group listener.

Okay so I have my ghost set to collisiongroup_01, my rigid body to group_02, and they both collide with group 3, which is the boxes. I am still getting the same effect. 8O

nvm fixed it with



if(event.getObjectA().getCollisionGroup() != this.getCollisionGroup()) return;



in the collision function.



Thanks for the help!

@raptorivaz said:
Okay so I have my ghost set to collisiongroup_01, my rigid body to group_02, and they both collide with group 3, which is the boxes. I am still getting the same effect. 8O

Read the javadoc, theres collision groups and collide with bit masks