Page 1 of 1

Problem with animating camera and node at the same time

Posted: Tue Sep 27, 2005 6:30 pm
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 ??

Posted: Tue Sep 27, 2005 6:43 pm
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.

Posted: Wed Sep 28, 2005 12:39 pm
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 ??

Posted: Wed Sep 28, 2005 12:49 pm
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.