# (Quaternion based) Trouble moving foward based on model rotation

Using quaternions, I'm having trouble moving my model in its facing direction. Currently the model moves can move in all cardinal directions with no problems. The problem comes when I rotate the move as it still travelling in the direction of world space. Meaning, if I'm moving forward, backward or any other direction while rotating the model, the model acts like its a figure skater spinning while traveling in the same direction.

How do I update the direction of travel proper with the facing direction of the model?

Rotates model on Y-axis:

``````        Yaw = pController.ThumbSticks.Right.X * MathHelper.ToRadians(speedAngleMAX);
``````

Moves model forward:

``````        // Move Forward
if (pController.IsButtonDown(Buttons.LeftThumbstickUp))
{
SpeedX = (float)(Math.Sin(ModelLoad.ModelRotation)) * FWDSpeedMax * pController.ThumbSticks.Left.Y * (float)gameTime.ElapsedGameTime.TotalSeconds;
SpeedZ = (float)(Math.Cos(ModelLoad.ModelRotation)) * FWDSpeedMax * pController.ThumbSticks.Left.Y * (float)gameTime.ElapsedGameTime.TotalSeconds;
// Update model position
}
``````
-

The problem stems from these lines:

``````        ModelLoad._modelPos += Vector3.Forward * SpeedZ;
``````

Both `Vector3.Forward` and `Vector3.Left` are in world space, while you'd rather have the controller change the direction in the (rotated) object space of the model.

The easiest solution (warning: Don't know XNA that good to know if it is the fastest solution as well) would be to calculate the displacement as above, then rotate it with the quaternion (or in 2D space, complex number) describing the model orientation, then adding that to change the model position:

``````Vector3 Displacement = Vector3.Forward * SpeedZ + Vector3.Left * SpeedX;