title: DirectX11 Camera Movement
body: <p>So I was programming some movement on a car I have in my program here. </p>
  
  <p>Do I just increase the <code>Z position</code> of the camera on <code>XMVECTOR pos</code>? I did this earlier and it went forward and all but started to turn the camera towards the ground.</p>
  
  <p><code>XMVECTOR pos = XMVectorSet(x, y, z + mCarTranslation.z, 1.0f);</code> </p>
  
  <p>Anyways here's part of my code.</p>
  
  <pre><code>/ Convert Spherical to Cartesian coordinates.
  float x = mRadius*sinf(mPhi)*cosf(mTheta);
  float z = mRadius*sinf(mPhi)*sinf(mTheta);
  float y = mRadius*cosf(mPhi);
  
  mEyePosW = XMFLOAT3(x, y, z);
  
  // Build the view matrix.
  XMVECTOR pos    = XMVectorSet(x, y, z, 1.0f);
  XMVECTOR target = XMVectorZero();
  XMVECTOR up     = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
  
  XMMATRIX V = XMMatrixLookAtLH(pos, target, up);
  XMStoreFloat4x4(&amp;mView, V);
  
  // Button down event.
  if (GetAsyncKeyState('W') &amp; 0x8000)
  {
      mCarTranslation.z += -4.0f*dt;
  }
  if(GetAsyncKeyState('S') &amp; 0x8000)
  {
      mCarTranslation.z += 2.0f*dt;
  }
  if(GetAsyncKeyState('A') &amp; 0x8000)
  {
      mCarTranslation.x += 1.0f*dt;
  }
  if(GetAsyncKeyState('D') &amp; 0x8000)
  {
      mCarTranslation.x += -1.0f*dt;
  }
  
  XMMATRIX carScale = XMMatrixScaling(0.5f, 0.5f, 0.5f);
  XMMATRIX carOffset = XMMatrixTranslation(mCarTranslation.x, mCarTranslation.y, mCarTranslation.z);
  XMStoreFloat4x4(&amp;mCarWorld, XMMatrixMultiply(carScale, carOffset));
  </code></pre>