I got this FPSCamera (the player) and this animated MD2 mesh (the enemy). I want the enemy to rotate toward the player, then move forward towards it (Mesh move towards camera).
This is the main loop code (By the way, I'm using my own little interface to Irrlicht, but it shouldn't be too hard to figure out ;)):
Code: Select all
//main loop
while(Running())
{
vector3df v = getTargetAngle(aiObj.node->getPosition(),camera.camera->getPosition()); //get angle between camera and mesh
vector3df aiv = aiObj.node->getPosition();
vector3df civ = camera.camera->getPosition();
//aiObj.node->setRotation(v);
//printf("aiobjxyz = %f,%f,%f\n",aiv.X,aiv.Y,aiv.Z);
//printf("camxyz = %f,%f,%f\n",civ.X,civ.Y,civ.Z);
vector3df v2 = vector3df(0.3,0.0,0.0);
v2.rotateXZBy(0.1,v);
aiObj.node->setPosition(aiObj.node->getPosition()+v2);
//then setPosition(getPosition+ newvector)
render();
}
//quit and close down
end();
I'm not quite sure on the logic I need to do this. So once again, I just gotta get the MD2 model to rotate towards me, the FPSCamera, and move towards it.
Thanks in advance. :)