Camera follow player?
Camera follow player?
I set my mesh node as the parent of my camera scene node. So when I rotate my player the camera follows it, but when I go forward the camera looks away. Is a library bug or I made some mistakes?
if you want a camera which stays 'behind' a node (like a 3rd person camera) then try this:
note that updateAbsolutePosition() is protected so you will not be able to call it unless you derive your own camera class or hack the irrlicht source. the reason that i call it is because i have experianced camera 'stutter' if i don't call updateAbsolutePosition() before the render.
Code: Select all
// this should go somewhere in your update loop
vector3df forward( sin( node->getRotation().Y*PI/180.0f ), -1, cos( node->getRotation().Y*PI/180.0f ) );
//now position the camera 50 units behind and above node, looking
//at it's bottom
camera->setPosition( node->getPosition() - forward*50.0f );
camera->setTarget( node->getPosition() );
//make sure the camera is updated
camera->updateAbsolutePosition();
I have heard that the IrrLicht engine does not actually enforce transformation changes until the frame after they were called. perhaps this simply forces it to?the reason that i call it is because i have experianced camera 'stutter' if i don't call updateAbsolutePosition() before the render.
a screen cap is worth 0x100000 DWORDS
i read that somewhere as well, and that is exactly why i call updateAbsolutePosition() when i make a change i want it updated RIGHT NOW... no patiencekeless wrote:I have heard that the IrrLicht engine does not actually enforce transformation changes until the frame after they were called. perhaps this simply forces it to?the reason that i call it is because i have experianced camera 'stutter' if i don't call updateAbsolutePosition() before the render.
but like i said, it fixed problems i was having with camera stutter which is a good thing. my camera is a derived class so it isn't any trouble to call it.