And for some reason when I parent a camera to my ship.. It doesn't follow it properly.. I mean it is right on start but if I move my ship the camera goes off in some strange direction...
Then I decided to use this code to move the camera around.. But it is so jerky..
Can anyone help me with this problem?
Code: Select all
void CPlayer::Update(long cTime) {
float elapsedTime = cTime * 0.001f;
//Move ship forward
vector3df pos = node->getPosition();
vector3df dir = forward->getAbsolutePosition() - pos;
dir.normalize();
pos += dir * (moveSpeed * elapsedTime);
node->setPosition(pos);
//Update camera
matrix4 m;
m.setRotationDegrees( node->getRotation() );
vector3df target = vector3df(0, 0, 1.0f);
vector3df upVec = vector3df(0, 1.0f, 0);
m.transformVect(target);
target += forward->getAbsolutePosition();
m.transformVect(upVec);
camera->GetCamera()->setUpVector(upVec);
camera->GetCamera()->setTarget(target);
camera->GetCamera()->setPosition(cameraPosition->getAbsolutePosition());
}