Attaching camera to a meshSceneNode
Posted: Sat Sep 02, 2006 4:49 am
I am doing a simplistic game with a spaceship and some asteroids. I want to attach the camera to the spaceship so that when i move the spaceship the camera should move with it. I create the camera scenenode using
then I set its position so that it is just above and behind the spaceship. Consider spaceShip to be the scene node of the spaceship,
now when I parent the camera to the spaceship using this
cam->setParent(spaceShip) and i change the position of the spaceship, the camera position remains the same. I have seen the camera's absolute position which is always (0,0,0) whereas the relative position remains the same as was given by cam->setPosition. What am i doing wrong here?
I found a workaround which is to adjust the camera position whenever the spaceship position changes so that it is always having the same offset from its parent i.e the spaceship but then why should i do this when it should have been handled automatically?
Code: Select all
ICameraSceneNode cam* = smgr->addCameraSceneNode();now when I parent the camera to the spaceship using this
cam->setParent(spaceShip) and i change the position of the spaceship, the camera position remains the same. I have seen the camera's absolute position which is always (0,0,0) whereas the relative position remains the same as was given by cam->setPosition. What am i doing wrong here?
I found a workaround which is to adjust the camera position whenever the spaceship position changes so that it is always having the same offset from its parent i.e the spaceship but then why should i do this when it should have been handled automatically?