Code: Select all
void Player::moveForward()
{
irr::core::vector3df oldPos( playerMesh->getPosition());
irr::core::vector3df direction(0,0,1); // front of your model (the direction of the nose)
cam->GetIrrCamNode()->updateAbsolutePosition();
core::CMatrix4<float> tempMat(cam->GetIrrCamNode()->getAbsoluteTransformation());
tempMat. rotateVect(direction);
direction.Y = 0.f;
direction.normalize();
const float SPEED = 10.f; // or whatever value
direction *= SPEED;
playerMesh->setPosition(oldPos+direction);
}