I'm having a really annoying problem with a camera. I'm trying to do a really simple third person "game", but the camera seems to be "failing". I tried the the third person camera from the FAQ ( this one ) but it is more than what i need, so i reduced it to:
Code: Select all
void followingCamera::Update() {
core::vector3df currTargetPos = m_pTargetNode->getPosition();
m_cam->setPosition( currTargetPos + rotacion );
m_cam->setTarget( currTargetPos ); //look at Target position
}
Where "rotacion" is a vector to set the rotation and height of the camera:
Code: Select all
void followingCamera::Rotate(irr::f64 angle) {
rotacion = core::vector3df(m_leash, m_height, 0);
rotacion.rotateXZBy( angle, core::vector3df(0, 0, 0) );
}
Code: Select all
core::vector3df newPos = target->getPosition() +
core::vector3df(( keys[KEY_KEY_S] ? 30.0f : -30.0f), 0, 0);
target->setPosition( newPos );
Code: Select all
while(device->run())
{
// Check Keys
g_cam->Update();
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
Sleep(250); // Limit to ~4 FPS
}
Click here
But when i move the target node (the one the camera follows), for 1 frame the camera get this position:
Click here
I've no idea what's going on, it seems that the camera target gets updated in the next frame, but the cam position remains the same for that frame and gets update in the other frame, producing a "bounce" effect.
From here you can download a Windows EXE (Irrlicht 0.11, the DLL is not in the rar):
http://www.angra.alejolp.com.ar/IRR/Pru ... -NoDLL.rar
Thanks in advance,
Alejandro.