Fixed player jump

This commit is contained in:
Robin Engman 2014-02-26 10:05:18 +01:00 committed by Dander7BD
parent 5a74f5368f
commit 5675155be4
1 changed files with 6 additions and 6 deletions

View File

@ -70,7 +70,7 @@ void Player::BeginFrame()
Oyster::Math::Float maxSpeed = 30; Oyster::Math::Float maxSpeed = 30;
// Rotate player accordingly // Rotate player accordingly
this->rigidBody->AddRotationAroundY(this->rotationUp); this->rigidBody->AddRotationAroundY(this->rotationUp);
this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized());
// Direction data // Direction data
@ -119,7 +119,7 @@ void Player::BeginFrame()
} }
// Dampen velocity if certain keys are not pressed // Dampen velocity if certain keys are not pressed
if(key_jump <= 0.001 && IsWalking()) if(key_jump <= 0.001 && IsWalking())
{ {
if(key_forward <= 0.001 && key_backward <= 0.001) if(key_forward <= 0.001 && key_backward <= 0.001)
{ {
@ -146,7 +146,7 @@ void Player::BeginFrame()
walkDirection.Normalize(); walkDirection.Normalize();
// If on the ground, accelerate normally // If on the ground, accelerate normally
if(IsWalking()) if(IsWalking())
{ {
if(forwardSpeed < maxSpeed) if(forwardSpeed < maxSpeed)
{ {
@ -158,7 +158,7 @@ void Player::BeginFrame()
} }
} }
// If in the air, accelerate slower // If in the air, accelerate slower
if(IsJumping()) if(IsJumping())
{ {
if(forwardSpeed < maxSpeed) if(forwardSpeed < maxSpeed)
{ {
@ -294,11 +294,11 @@ bool Player::IsWalking()
} }
bool Player::IsJumping() bool Player::IsJumping()
{ {
return (this->rigidBody->GetLambda() < 1.0f); return (this->rigidBody->GetLambda() == 1.0f);
} }
bool Player::IsIdle() bool Player::IsIdle()
{ {
return (this->rigidBody->GetLambda() < 1.0f && this->rigidBody->GetLinearVelocity().GetMagnitude() < 0.0001f); return (this->rigidBody->GetLambda() == 1.0f && this->rigidBody->GetLinearVelocity().GetMagnitude() < 0.0001f);
} }
void Player::Inactivate() void Player::Inactivate()