I have First Person Shooter camera setup, I notice a problem when the player (btCapsule) go down from the terrain heights to the ground.
btCapsule cause the player to fall from the terrain heights instead of moving normally which is not a character behavior, I'm trying to get the character to move on the heights normally.
When I set a higher gravity, the player appear bouncing on the terrain while going down (from height to ground).
Player capsule movement on terrain heights
That's usually what happens when your forward vector only rotates around the y-axis and only represents a direction along the (x,z) plane.
Here is what I use to move the capsule forward:
How can I fix it to make the capsule move normally on the heights?
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
X -= (elapsedTime * speed) * vecForward.x;
Y -= (elapsedTime * speed) * vecForward.y;
Z -= (elapsedTime * speed) * vecForward.z;
// -- Move btCapsuleShape forward
body->translate(btVector3(X - trans.getOrigin().getX(), Y - trans.getOrigin().getY(), Z - trans.getOrigin().getZ()));
How can I fix it to make the capsule move normally on the heights?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement