•      Sign In
• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

#ActualMedo3337

Posted 24 March 2013 - 04:50 AM

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?

#2Medo3337

Posted 23 March 2013 - 08:53 AM

I'm moving the player FORWARD, but the I have 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?

#1Medo3337

Posted 23 March 2013 - 08:46 AM

I'm moving the player FORWARD, but the I have 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 (rotY != 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?

PARTNERS