best way to feed collision result into logical object.

khoowaikeong
Posts: 43
Joined: Fri Jun 15, 2012 7:11 am

best way to feed collision result into logical object.

Post by khoowaikeong »

so far bullet does physic great, but now we need to link the collision result to the logical object so the script can be trigger.

currently our logical object contains 3 collision object:
body(recieve damage & collision)
weapon(cause damage)
ghost(trigger)

the result we get from bullet such as 'm_pProxy0' appears to be pointer to these collision object. however they don't know what to do, so the dumb idea i have now is to loop all the logical object and find the owner of the collision object then trigger their functions. now i been wondering if I am doing it wrong. if the pointer that is return to us are collision object, can we create an object that inherits from collision object that has function to trigger the script directly?... and simply cast m_pProxy0 back into our new 'collision object with script trigger' class?

would such a casting work? or are there better way of doing it that i missed?
xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: best way to feed collision result into logical object.

Post by xexuxjy »

Well you can set a user object on each of your collision objects which could be a pointer back to your real object, or a key to a table where the object is or whatever. Bullet just stores it as a (void*) . I often set it to point to the owning game object (which I also assign an ICollideable type interface to) so I can they just cast them to a know type and let them figure out the collision result themselves.