2 camera problem

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
esmanical
Posts: 2
Joined: Tue Apr 26, 2005 2:20 pm
Location: Serbia

2 camera problem

Post by esmanical »

I'm having problem with this demo I'm working on. I have 2 cameras, one is :

camera2 = sm->addCameraSceneNodeFPS(0, 100.0f, 600.0f, -1, keyMap, 8 );

and the other one is:
camera = smgr->addCameraSceneNode(BackNode,core::vector3df(0, 100, 0), core::vector3df(0, 0, -1));

During the game camera is folowing my character, and when I press ENTER I want to take a free look around.So when I press ENTER this function is called:

void CDemo::switchcamera()
{
freelook = (!freelook);
freelook ? smgr->setActiveCamera(camera2) : smgr->setActiveCamera(camera);
if(freelook)
{
camera2->setPosition(camera->getAbsolutePosition());
camera2->setTarget(camera->getTarget());

}
}

The point is that when switching camera I want to have the same look with my freelook camera (camera2), but its not like that. After switching camera 2 position is ok (same as camera position), but it looks somewhere up, not in my character. I cant solve this problem, anyone?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

just a guess, but perhaps 'camera' has no target as 'camera2' is now the active camera.
esmanical
Posts: 2
Joined: Tue Apr 26, 2005 2:20 pm
Location: Serbia

Post by esmanical »

No, I changed the code like this:

camera2->setTarget(EmptyNode->getAbsolutePosition());

and this EmptyNode is actually where my camera is looking at, and its allways there so... sthank you, Anyone?
Post Reply