Can I control the collision myself?

challenge

27-09-2008 11:22:46

I just want to do something myself (like change direction etc) when two objects meet each other. And I don't want them to collide, could I realize that? How to?
Thanks for your answer :)

rewb0rn

28-09-2008 09:06:05

yes you can: return false in the collision method and add forces yourself.

challenge

29-09-2008 03:07:41

Thanks, I've tried. While I wonder that if I returned false in the collision func, where should I add force? :)

rewb0rn

29-09-2008 18:18:02

also in the collision method.

challenge

02-10-2008 08:58:54

Thank you. I've tried and it doesn't make sense. :( Here is my code, I just want the object to change it's Orientation when collision happens.
bool collision(OgreOde::Contact* contact){
// you can do more or less with this function (like nothing.) See the OgreOde examples for some ideas.
if (cf.getSetting("Friction", "Ball") == "infinity")
contact->setCoulombFriction(OgreOde::Utility::Infinity);
else
contact->setCoulombFriction(StringConverter::parseReal(cf.getSetting("Friction", "Ball")));

contact->setBouncyness(StringConverter::parseReal(cf.getSetting("Bouncyness", "Ball")));

if(Rotated == false)
{
SceneNode *mPNode;
mPNode=mSceneMgr->getEntity("Entity2")->getParentSceneNode();
Vector3 src = mPNode->getOrientation( ) * Vector3::UNIT_Y;
Ogre::Quaternion quat = src.getRotationTo(Vector3(1,1,1));
mPNode->rotate( quat ,Node::TS_PARENT);
Rotated=true;
}

return false;
}