I'm moving the player FORWARD, but I have a slight problem, when the player move on the terrain heights (mountain), the player fall on the terrain instead of moving normally, which make the player appear like they are able to fly, see the attached picture.
Here is the code that I'm using for moving forward:
D3DXMATRIX matRot; D3DXMatrixRotationYawPitchRoll(&matRot, D3DXToRadian(rotationX), D3DXToRadian(rotationY), D3DXToRadian(rotationZ)); D3DXMATRIX ZUnitVec; D3DXVECTOR3 vecForward; D3DXMatrixTranslation(&ZUnitVec, 0.0f, 0.0f, 1.0f); // Matrix holding position of vector pointing to positive Z D3DXMATRIX m = ZUnitVec * matRot; vecForward = D3DXVECTOR3(m._41,m._42,m._43); // Get vector from the matrix newX -= (elapsedTime * speed) * vecForward.x; if (rotationY != 1.0f) newY -= (elapsedTime * speed) * vecForward.y; newZ -= (elapsedTime * speed) * vecForward.z;
How do I modify the above code to make the player move on the terrain normally, without flying?
Edited by Medo3337, 24 March 2013 - 04:50 AM.