hiding a body

Grom

22-01-2007 03:44:24

I want to hide a body, it's a ball one of my characters will throw. I don't want it waiting around, I want to hide it until it's time to throw it. Right now, I put it way out of the scene and do this:

sceneMgr->getEntity("ball")->setVisible(false);
mScene->findBody("ball")->putToSleep();


Then when it's time to use it, I move it to the appropriate place and do this:

sceneMgr->getEntity("ball")->setVisible(true);
mScene->findBody("ball")->wakeUp();


Is there a better way to do it?

betajaen

22-01-2007 10:54:03

No that's fine. You may want to put it in non-collision group when hiding just in case someone trips over the invisible sphere. :D

luis

22-01-2007 11:15:57

My advice for the Ogre side:
If you're going to hide more objects ( >= 2 ) i would detach entity from the scenenode and the scenenode from the root scenenode since non visible objects have CPU overhead in Ogre.

betajaen

22-01-2007 11:40:09

If your going to go that extent, you may as well delete it and create it when needed.

It just depends how long the ball is invisible for.