# [solved] how to detect whether A collide B or B collide A?

Hi,
I am using E_PHYSICSCOLLISIONSTART for a physic listener in class derived from Application, and now no matter whether node A collide node B or B collide A, the eventData is the same, the NodeA is A and NodeB is B, this confusing me.
Is there any way to distinguish which node collide with the other?
Thank you!

Edit:
Because my goal is detect whether back car collide with front car, the solution that the function RaycastSingle or Raycast is a perfect way to solve the problem.
Thank you all very much!

If you look at the code which sending this event, you will find a logic that sort the bodyA and bodyB, which in turns should make nodeA and nodeB always appear in the event data in a similar order when the pair collides with each other.
github.com/urho3d/Urho3D/blob/m … #L650-L654

But I can’t catch you.
My game has two car, the node A and node B, I can’t distinguish which one collide with the other. The event data is the same, no matter A collide B or B collide A.
My meaning is that, if A collide B, then the event data will contains NodeA is A, and NodeB is B, and if B collide A, the event data would contains NodeA is B, and NodeB is A. Or is there any way to distinguish the two nodes?

From the point of the physics simulation (Bullet library) collision is interaction of two objects, so the question whether A collides with B or B collides with A is not relevant, or actually, both happen.

Collisions are hard to handle from that global collision event, as it’s fired for every colliding pair of objects. It’s possible that the “node A” or “node B” might swap between simulation steps (especially if the collision is broken off and then starts again) so you can’t rely on which is which.

Typically a game might be running a car logic script or component in the same node as the car rigidbody/collisionshape, and each such car logic object would listen to its own node’s collision events only: the NodeCollision category of events. Those events are easier to use as they have an “other node” parameter. Like this:

``````SubscribeToEvent(GetNode(), E_NODECOLLISIONSTART, HANDLER(MyLogicObject, HandleNodeCollisionStart));

void MyLogicObject::HandleNodeCollisionStart(StringHash eventType, VariantMap& eventData)
{
using namespace NodeCollisionStart;
Node* collidedWith = eventData[P_OTHERNODE].GetPtr();
...
}``````