Hi,
I need to trigger an action when a certain object in my scene gets hit. How would I go about doing this? Is getCollisionflag() useful for this? Does it notify me when this object has been hit?
Collisions?
-
- Posts: 107
- Joined: Fri Sep 19, 2008 6:08 pm
Re: Collisions?
Hi
See if this wiki entry here can help you out:
http://www.bulletphysics.com/mediawiki- ... d_Triggers
See if this wiki entry here can help you out:
http://www.bulletphysics.com/mediawiki- ... d_Triggers
-
- Posts: 10
- Joined: Mon Sep 08, 2008 2:27 am
Re: Collisions?
Thanks, have got it sort of working but I have a small problem. In my project I am throwing a ball in a rectangular room and I want to trigger a certain event if I hit the object in the middle of the room. At the moment I am using the gContactAddedCallback and it works. If a ball hits that object it will trigger the event. But for my application I only want to trigger an event if the ball hits the object without bouncing off anything else. How can I achieve this?
I'm using this function from one of the bullet demos to handle the collision detection:
Is what I want to do achievable by modifying this function or do I need another approach?
I'm using this function from one of the bullet demos to handle the collision detection:
Code: Select all
bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
{
if (colObj0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
}
if (colObj1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
//trigger event
}
return true;
}
-
- Posts: 107
- Joined: Fri Sep 19, 2008 6:08 pm
Re: Collisions?
I'm not too sure but I'll try:
A. I think there's a way so that when your object collides with another object, it does not resolve anything (eg bounce/push the other objects away) - you probably do this by setting some flags or group them. Sorry if I'm a little vague as I'm not very sure entirely.
B. gContactAddedCallback - do you think you can use this instead? So before the collision gets processed, remove the object from the dynamics world?
A. I think there's a way so that when your object collides with another object, it does not resolve anything (eg bounce/push the other objects away) - you probably do this by setting some flags or group them. Sorry if I'm a little vague as I'm not very sure entirely.
B. gContactAddedCallback - do you think you can use this instead? So before the collision gets processed, remove the object from the dynamics world?
-
- Posts: 10
- Joined: Mon Sep 08, 2008 2:27 am
Re: Collisions?
mickey, thanks for your help but unfortunately I'm still stuck. Does anybody know how I can do this?
-
- Posts: 4
- Joined: Sun Mar 15, 2009 7:20 pm
Re: Collisions?
Store a flag that gets set if the object bounces off something else, then only act if the flag is unset.