How to detect which CollisionObject was hit ?

MusgooD
Posts: 8
Joined: Wed Jun 17, 2009 7:52 am

How to detect which CollisionObject was hit ?

Post by MusgooD »

I have 2 CollisionObject with the same ShapeType (for example btBoxShape)

- how to detect which of them was hit by Ray ?
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: How to detect which CollisionObject was hit ?

Post by pico »

Hi,

you can use the public property m_userObjectPointer in the collisionObject to store user data.
MusgooD
Posts: 8
Joined: Wed Jun 17, 2009 7:52 am

Re: How to detect which CollisionObject was hit ?

Post by MusgooD »

Hi pico

Thanks for reply,
Ok, i marked/customized all CollisionObjects, each object have it's own number.

But how i can get access to userdata from RayResultCallback ?
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: How to detect which CollisionObject was hit ?

Post by pico »

Hi,

you can access the ray result m_collisionObject.

I'm not sure why you want to know the shape. Usually people use the m_userData in m_collisionObject for a pointer to their internal game object structure.
If you just need to seperate objects you can use different filtergroups.
MusgooD
Posts: 8
Joined: Wed Jun 17, 2009 7:52 am

Re: How to detect which CollisionObject was hit ?

Post by MusgooD »

Thanks pico

Code: Select all

	if (resultCallback.hasHit())
	{
		return resultCallback.m_collisionObject;
	}
I get it ! :)