Jump to content

  • Log In with Google      Sign In   
  • Create Account

Player capsule movement on terrain heights


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 18 December 2012 - 11:16 PM

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).

Attached Thumbnails

  • player falling.png

Edited by Medo3337, 19 December 2012 - 12:11 AM.


Sponsor:

#2 Steve_Segreto   Crossbones+   -  Reputation: 1558

Like
0Likes
Like

Posted 19 December 2012 - 11:46 AM

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.

#3 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 19 December 2012 - 01:36 PM

Here is what I use to move the capsule 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

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?

#4 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 19 December 2012 - 02:32 PM

Hmm, I tried changing the line:
D3DXMatrixTranslation(&ZUnitVec, 0.0f, 0.0f, 1.0f);

To:
D3DXMatrixTranslation(&ZUnitVec, 0.0f, 1.0f, 1.0f);

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS