Player air check function
This commit is contained in:
parent
800f514028
commit
4b4255cfcc
|
@ -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 && this->rigidBody->GetLambda() < 0.9f)
|
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(this->rigidBody->GetLambda() < 0.9f)
|
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(this->rigidBody->GetLambda() >= 0.9f)
|
if(IsJumping())
|
||||||
{
|
{
|
||||||
if(forwardSpeed < maxSpeed)
|
if(forwardSpeed < maxSpeed)
|
||||||
{
|
{
|
||||||
|
@ -188,7 +188,7 @@ void Player::BeginFrame()
|
||||||
if(key_jump > 0.001)
|
if(key_jump > 0.001)
|
||||||
{
|
{
|
||||||
this->key_jump -= this->gameInstance->GetFrameTime();
|
this->key_jump -= this->gameInstance->GetFrameTime();
|
||||||
if(this->rigidBody->GetLambda() < 0.9f)
|
if(IsWalking())
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.GetNormalized();
|
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.GetNormalized();
|
||||||
this->rigidBody->ApplyImpulse(up*this->rigidBody->GetState().mass * 20);
|
this->rigidBody->ApplyImpulse(up*this->rigidBody->GetState().mass * 20);
|
||||||
|
@ -290,15 +290,15 @@ void Player::Jump()
|
||||||
|
|
||||||
bool Player::IsWalking()
|
bool Player::IsWalking()
|
||||||
{
|
{
|
||||||
return (this->playerState == PLAYER_STATE::PLAYER_STATE_WALKING);
|
return (this->rigidBody->GetLambda() < 0.99f);
|
||||||
}
|
}
|
||||||
bool Player::IsJumping()
|
bool Player::IsJumping()
|
||||||
{
|
{
|
||||||
return (this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING);
|
return (this->rigidBody->GetLambda() < 1.0f);
|
||||||
}
|
}
|
||||||
bool Player::IsIdle()
|
bool Player::IsIdle()
|
||||||
{
|
{
|
||||||
return (this->playerState == PLAYER_STATE::PLAYER_STATE_IDLE);
|
return (this->rigidBody->GetLambda() < 1.0f && this->rigidBody->GetLinearVelocity().GetMagnitude() < 0.0001f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Inactivate()
|
void Player::Inactivate()
|
||||||
|
|
Loading…
Reference in New Issue