So basically this is a problem I've been having since forever. I implemented a Camera System, it works fine but somewhere around the center (0, 0, 0) of the world it doesn't work. Actually it works, but it always moves back at the position I was before. Like, if I'm at (1, 0, 0), walking forward will make me stay at (1, 0, 0), while moving backwards will not. The weird thing is that as said before it only happens there and if I'm moving forwards, backwards, left and right work perfectly!

That's how I do my Walking:

XMVECTOR D = XMVectorReplicate(d);
XMVECTOR L = XMLoadFloat3(&m_LookDirection);
XMVECTOR P = XMLoadFloat3(&m_Pos);
XMStoreFloat3(&m_Pos, XMVectorMultiplyAdd(D, L, P));

My Strafing (Left to Right) is basically the same thing. I update my ViewMatrix like that:

XMVECTOR R = XMLoadFloat3(&m_Right);
XMVECTOR U = XMLoadFloat3(&m_Up);
XMVECTOR L = XMLoadFloat3(&m_Look);
XMVECTOR P = XMLoadFloat3(&m_Pos);
XMVECTOR WU = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);

//Compute wuv vectors for camera space
XMVECTOR w = XMVector3Normalize(XMVectorSubtract(L, P));
XMVECTOR u = XMVector3Normalize(XMVector3Cross(WU, w));
XMVECTOR v = XMVector3Cross(w, u);

XMStoreFloat3(&m_LookDirection, w);
XMStoreFloat3(&m_Right, u);
XMStoreFloat3(&m_Up, v);

Then I fill in the ViewMatrix but that's unimportant.

Hope someone knows that basic mistake I'm doing!



You could define your "look at" point to be the same as current position. In this case, this line:

XMVECTOR w = XMVector3Normalize(XMVectorSubtract(L, P));

will give you zero vector as forward direction, then you'll use it and of course there will be no movement

Simple example: you're at (0, 0, 0) and your look at point is (0, 0, 0)

Another possibility is that you're not moving your look at point, and when you cross it after some movement your forward direction negates thus moving you back

  • \$\begingroup\$ Thank you! This has helped me alot, especially the second point! ;D \$\endgroup\$
    – Rakete1111
    Nov 16 '14 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .