Code: Select all
if (receiver->IsKeyDown(KEY_KEY_W))
{
core::vector3df camPos = camera->getPosition();
core::vector3df camTar = camera->getTarget();
const f32 Xupdate = (f32)speed * deltaTime*direction.X;
const f32 Yupdate = (f32)speed * deltaTime*direction.Y;
camPos.X += Xupdate; camPos.Z += Yupdate;
camTar.X += Xupdate; camTar.Z += Yupdate;
camera->setPosition(camPos);
camera->setTarget(camTar);
}
Is this the best way to do this or can it be simplified in terms of code or optimized in terms of speed/memory?
And one side question, why did I have to update camPos.Z and camTar.Z instead of .Y for it to work?