Lose FPS Camera Functions

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
markanderson
Posts: 30
Joined: Thu Mar 16, 2006 6:21 pm

Lose FPS Camera Functions

Post by markanderson »

Hello All -

In my app, I have nodes drawn randomly throughout the 3D space and I have setup a FPS camera to let the user move around the space. I've recently added code that detects a double click. If the user double clicks on a node I wanted the camera to jump forward in that direction.

Here is my code for this behaviour:

Code: Select all

core::position2d < irr::s32 > mpos = device->getCursorControl()->getPosition();
scene::ISceneNode *selectedSceneNode = device->getSceneManager()->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(mpos, NODE_MASK);
if (selectedSceneNode > 0)
{
	core::vector3df campos  = device->getSceneManager()->getActiveCamera()->getAbsolutePosition();
	core::vector3df nodepos = selectedSceneNode->getAbsolutePosition();
	core::vector3df newpos = core::vector3df((campos.X+nodepos.X)/2, (campos.Y+nodepos.Y)/2, (campos.Z+nodepos.Z)/2);
	scene::ISceneNodeAnimator *sa = device->getSceneManager()->createFlyStraightAnimator(Camera->getPosition(), newpos, 200, 0);
	Camera->addAnimator(sa);
	sa->drop();
}
Obviously, the code works out a mid-point between the camera position and the node position and then flys the camera to that point. The problem is that after the camera flys to the position, the user looses FPS controls - they can't move around at all. The camera angle can still be changed by moving the mouse, but the arrows key no longer respond.

Can anyone suggest why this is?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

I guess the animator is still attached to the camera locking it into position every frame, you'll need to remove it manually
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply