Dboy85
12-02-2012 22:57:03
Hey all, What's the best practice for setting the name of a character in Bloody Mess. I'm trying to get to grips with ray casting and I'm trying the following:
hit.mRigidBody->getName() is empty so I'm obviously setting up the characters wrongly.
Ogre::Entity * mEnt = mSceneMgr->createEntity(name,meshName);
mNode->addEntity(mEnt);
...
mCharacter = mRenderSystem->createAnimatedCharacter( position , Ogre::Radian(0), mNode, desc);
So have I set up the character correctly in a way that I can retrieve the name from it at will?
If anyone has a code snippet that would be super, thanks.
P.S Another character related question. When I want to set a body as collide-able non pushable in the scene I set up the body description but it seems to ignore
this upon collision with an animated character. The body moves as if it was set to be pushable and I tested it by dropping another body on it and it didn't move so its the character.
I tried to set the body's dynamic flag as freeze position as a work around but then the collision doesn't happen at all.
Any help appreciated thanks
// TODO: RAY CAST AND FOLLOW PLAYER IF PATH IS CLEAR.
m_RaySource = m_Enemies.at(count)->getAnimChar()->getPosition();
m_RayDirection = (m_Enemies.at(count)->getAnimChar()->getPosition() - m_pPlayer->getPosition()).normalise();
NxOgre::Ray( NxOgre::Vec3(m_RaySource.x,m_RaySource.y,m_RaySource.z) , NxOgre::Vec3(m_RayDirection.x ,m_RayDirection.y,m_RayDirection.z) );
// Find the closest object that intersected the ray between the Player and Zombie.
NxOgre::RaycastHit hit = m_renderSys->getScene()->raycastClosestShape(m_Ray, NxOgre::Enums::ShapesType_Dynamic);
if(hit.mRigidBody)
{
Ogre::String name = hit.mRigidBody->getName();// Empty as usual.
if( hit.mRigidBody->getName() == "Player" )// etc...
{
// your code goes here
int x = 0;
}
}
hit.mRigidBody->getName() is empty so I'm obviously setting up the characters wrongly.
Ogre::Entity * mEnt = mSceneMgr->createEntity(name,meshName);
mNode->addEntity(mEnt);
...
mCharacter = mRenderSystem->createAnimatedCharacter( position , Ogre::Radian(0), mNode, desc);
So have I set up the character correctly in a way that I can retrieve the name from it at will?
If anyone has a code snippet that would be super, thanks.
P.S Another character related question. When I want to set a body as collide-able non pushable in the scene I set up the body description but it seems to ignore
this upon collision with an animated character. The body moves as if it was set to be pushable and I tested it by dropping another body on it and it didn't move so its the character.
I tried to set the body's dynamic flag as freeze position as a work around but then the collision doesn't happen at all.
Any help appreciated thanks