[SOLVED] Raycast okay and deleting actor + body

spacegaier

09-03-2008 11:55:46

Hello togheter. I'm trying to work with raycast at the moment and seems to be quite easy. However I got a slight problem.

I figure out the closest actor hit by the raycast. No I want to delete this actor AND its body! How can I do that? And is my code right and good?

Ogre::Vector3 pos = m_pPlayer1Character->getGlobalPosition();
Ogre::Quaternion ori = m_pPlayer1Character->getGlobalOrientation();
Vector3 dir = ori * Vector3::UNIT_Z;

NxOgre::RayCaster *rc = new NxOgre::RayCaster(pos, dir.normalisedCopy(), 20, NxOgre::RayCaster::RCT_ALL, m_pNxScene);

if(rc->castShape(NxOgre::RayCaster::AF_NONE))
{
for(NxOgre::RayCastHit* aHit = &rc->mReport._begin(); !rc->mReport._atEnd(); aHit = &rc->mReport._next())
{
m_pLog->logMessage("RayCastHit");
NxOgre::Actor *actor = rc->getClosestActor();
actor->_destroyActor();
}
}

betajaen

09-03-2008 12:48:24

No it's:

Scene* actors_scene = actor->getScene();
actors_scene->destroyActor(actor);

spacegaier

09-03-2008 14:27:22

Thanks. Functions well.