Problem with animating camera and node at the same time

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
lor
Posts: 22
Joined: Sat Aug 27, 2005 2:07 pm

Problem with animating camera and node at the same time

Post by lor »

firstly, the code:

Code: Select all

   		   ISceneNodeAnimator* przejdz = smgr->createFlyStraightAnimator(akt_poz, idz_do, odleglosc*10,0);
   		   rydzyk->addAnimator(przejdz);
   		   przejdz->drop();
		camera->setTarget(vector3df(rydzyk->getAbsolutePosition().X,0,rydzyk->getAbsolutePosition().Z-90));
   		camera->setPosition(vector3df(rydzyk->getAbsolutePosition().X,300,rydzyk->getAbsolutePosition().Z-90));
now some explains: my model moves, my camera target has the same coordinates as model, and my camera is 500 points above the model - it can move only in X and Z planes. Now up to the point, how to make those 3 things move at the same time ??
CZestmyr
Posts: 72
Joined: Sat Feb 12, 2005 7:11 pm
Location: Czech Republic
Contact:

Post by CZestmyr »

Ever heard about parenting objects? Every scene node in the scene can be made a parent of an other node. Try putting following code before creation of the animator:

Code: Select all

camera->setParent(rydzyk);
The camera target is relative to the translation of the camera, so i guess it should move with the camera.
lor
Posts: 22
Joined: Sat Aug 27, 2005 2:07 pm

Post by lor »

Doesn't work. :roll: the camera desn't move the same direction as node and the camera target doesn't move at all. So the camera view starts to rotate and this is what I'm trying not to get.... Any other ideas ??
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

So in your main loop, in every frame, set your camera's target to the nodes position. Then set your camera's position to the targets, x,z but leave the camera position's Y at 500.
Image
Post Reply