Archive 17/01/2023.

Detecting Collisions

Sean221

I’m having trouble with collisions. I looked on the forums and found that i should be using

SubscribeToEvent(_node, E_NODECOLLISION, URHO3D_HANDLER(Main, HandleCollision));

but how do i tell which rigidbody has collided with the object?

Also can someone tell me why when i try and put the SubscribeToEvent in a different class that isn’t inheriting from Sample it doesn’t recognize it?

If anyone else cant figure it out this worked for me
RigidBody* body = static_cast<RigidBody*>(eventData[NodeCollision::P_BODY].GetPtr());

Eugene

Maybe I didn’t understand the question, but event parameter contain enough data, don’t they?

You shoud have your class derived from the Object. Should be enough.

Sean221

How would i go about getting the URHO3D_PARAM?

ive tried RigidBody* body = static_cast<RigidBody*>(eventData[P_BODY].GetPtr());

but that didnt work

Eugene

What about NodeCollision::P_BODY? Well, just use any sampe or piece of engine code as reference.