lullideath
06-09-2006 22:04:02
i am trying to get the enemy turn to the player and then run towards the player, here is the all the stuffs I have for turning, which works great alone:
Ogre::Vector3 mDirection = player->getWorldPosition() - mBody->getGlobalPosition();
mDirection.y = 0;
mDirection.normalise();
Ogre::Vector3 src = mBody->getGlobalPosition() * Ogre::Vector3(0,0,-1);
Ogre::Quaternion quat = src.getRotationTo( mDirection );
mBody->mNode->setOrientation(quat);
after that, I want the enemy run to the player, so i added a simple force after the last line of the turning code above:
mBody->addForce(mDirection*speed);
now, the enemy no longer turn its body anymore - it faces the original direction all the time, while moving towards the player...
Any help would be great!!!!!!!!!!!!!!
thanks a lot!!!
lullideath
Ogre::Vector3 mDirection = player->getWorldPosition() - mBody->getGlobalPosition();
mDirection.y = 0;
mDirection.normalise();
Ogre::Vector3 src = mBody->getGlobalPosition() * Ogre::Vector3(0,0,-1);
Ogre::Quaternion quat = src.getRotationTo( mDirection );
mBody->mNode->setOrientation(quat);
after that, I want the enemy run to the player, so i added a simple force after the last line of the turning code above:
mBody->addForce(mDirection*speed);
now, the enemy no longer turn its body anymore - it faces the original direction all the time, while moving towards the player...
Any help would be great!!!!!!!!!!!!!!
thanks a lot!!!
lullideath