look always to the camera

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
leninbooter
Posts: 1
Joined: Tue Oct 05, 2010 3:01 am

look always to the camera

Post 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
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post 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)
Post Reply