Sign in to follow this  

Player capsule movement on terrain heights

This topic is 1854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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). Edited by Medo3337

Share this post

Link to post
Share on other sites
Here is what I use to move the capsule forward:[CODE]
D3DXMatrixRotationYawPitchRoll(&matRot, D3DXToRadian(rotationX), D3DXToRadian(rotationY), D3DXToRadian(rotationZ));
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?

Share this post

Link to post
Share on other sites
Hmm, I tried changing the line:
[CODE]D3DXMatrixTranslation(&ZUnitVec, 0.0f, 0.0f, 1.0f);[/CODE]

[CODE]D3DXMatrixTranslation(&ZUnitVec, 0.0f, 1.0f, 1.0f);[/CODE]

Now, I don't see the problem anymore, is that the correct way to move forward?

Share this post

Link to post
Share on other sites
Sign in to follow this