Fixing player animation updates
This commit is contained in:
parent
8111e9f51e
commit
97ea35e91e
|
@ -71,9 +71,6 @@ void Player::BeginFrame()
|
||||||
{
|
{
|
||||||
weapon->Update(0.002f);
|
weapon->Update(0.002f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Oyster::Math::Float maxSpeed = 30;
|
Oyster::Math::Float maxSpeed = 30;
|
||||||
|
|
||||||
// Rotate player accordingly
|
// Rotate player accordingly
|
||||||
|
@ -137,15 +134,11 @@ void Player::BeginFrame()
|
||||||
rightVelocity *= Oyster::Math::Float3(0.2f*fabs(rightDir.x), 0.2f*fabs(rightDir.y), 0.2f*fabs(rightDir.z));
|
rightVelocity *= Oyster::Math::Float3(0.2f*fabs(rightDir.x), 0.2f*fabs(rightDir.y), 0.2f*fabs(rightDir.z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(IsIdle())
|
||||||
if(walkDirection == Oyster::Math::Float3::null)
|
|
||||||
{
|
{
|
||||||
if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING)
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_IDLE)
|
||||||
{
|
this->gameInstance->onActionEventFnc( this, PlayerAction::PlayerAction_Idle);
|
||||||
if(this->playerState != PLAYER_STATE::PLAYER_STATE_IDLE)
|
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||||
this->gameInstance->onActionEventFnc( this, PlayerAction::PlayerAction_Idle);
|
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Walk if walkdirection is something
|
// Walk if walkdirection is something
|
||||||
if(walkDirection != Oyster::Math::Float3::null)
|
if(walkDirection != Oyster::Math::Float3::null)
|
||||||
|
@ -176,12 +169,13 @@ void Player::BeginFrame()
|
||||||
rightVelocity += walkDirection*Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z)) * walkSpeed*0.2f;
|
rightVelocity += walkDirection*Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z)) * walkSpeed*0.2f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING)
|
// TODO not suer if we want to keep jump animation while jumping
|
||||||
{
|
//if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING)
|
||||||
|
//{
|
||||||
if(this->playerState != PLAYER_STATE::PLAYER_STATE_WALKING)
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_WALKING)
|
||||||
this->gameInstance->onActionEventFnc( this, PlayerAction::PlayerAction_Walk);
|
this->gameInstance->onActionEventFnc( this, PlayerAction::PlayerAction_Walk);
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
this->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust velocities so no squaring occurs
|
// Adjust velocities so no squaring occurs
|
||||||
|
@ -205,14 +199,6 @@ void Player::BeginFrame()
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if(this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING)
|
|
||||||
{
|
|
||||||
this->gameInstance->onActionEventFnc( this, PlayerAction::PlayerAction_Idle);
|
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +291,7 @@ bool Player::IsJumping()
|
||||||
}
|
}
|
||||||
bool Player::IsIdle()
|
bool Player::IsIdle()
|
||||||
{
|
{
|
||||||
return (this->rigidBody->GetLambdaUp() == 1.0f && this->rigidBody->GetLinearVelocity().GetMagnitude() < 0.0001f);
|
return (this->rigidBody->GetLambdaUp() < 1.0f && this->rigidBody->GetLinearVelocity().GetMagnitude() < 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Inactivate()
|
void Player::Inactivate()
|
||||||
|
|
Loading…
Reference in New Issue