Page 1 of 1

look always to the camera

Posted: Tue Oct 05, 2010 3:03 am
by leninbooter
hi, can anybody help me hot to make an animated mesh, especially an enemy in a game, always to look at the camera, and move to the same position of the camera, thanks

Posted: Tue Oct 05, 2010 6:34 am
by Midnight
all depends on your code.

the general concept would be to setup your "camera" as a target, lets say camera->irrlichtCameraCode(blah);

now I imagine your "enemy" is a node...

node->animatedMesh(blah);

if(camera)
node->setRotation(camera);

In your real code you might need to use the Cameras position rather then the Camera node itself, it might look something like this.

CamPos = (rect<s32>0,0,0,0)
CreateCamera(campos,otherjunk);

And then when you create the camera you update the cam position.

campos = getCamPos();

then obviously you update the "enemy" nodes rotation to the cameras position. it's all rather logical, I hope you're not too confused by my pretend psuedo-code.

Hope that helps, happy coding! 8)