diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 396f34eab6..b09bcac4d8 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -251,6 +251,7 @@ namespace MWMechanics } iter->second.setState(CharState_Dead); + iter->second.setDirection(Ogre::Vector3::ZERO); ++mDeathCount[MWWorld::Class::get(iter->first).getId(iter->first)]; @@ -264,7 +265,22 @@ namespace MWMechanics { for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) { + if(iter->second.getState() == CharState_Dead) + continue; + Ogre::Vector3 dir = MWWorld::Class::get(iter->first).getMovementVector(iter->first); + CharacterState newstate = CharState_Idle; + + if(dir.length() >= 0.1f) + { + if(dir.y < 0.0f) + newstate = CharState_WalkBack; + else + newstate = CharState_WalkForward; + } + + if(iter->second.getState() != newstate) + iter->second.setState(newstate); iter->second.setDirection(dir); } diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index b6adec0681..f3a1f2fba7 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -188,6 +188,18 @@ void CharacterController::setState(CharacterState state) mAnimation->setAccumulation(Ogre::Vector3::ZERO); mAnimation->play(mCurrentGroup, "start"); break; + + case CharState_WalkForward: + mCurrentGroup = "walkforward"; + mAnimation->setAccumulation(Ogre::Vector3(0.0f, 1.0f, 0.0f)); + mAnimation->play(mCurrentGroup, "start"); + break; + case CharState_WalkBack: + mCurrentGroup = "walkback"; + mAnimation->setAccumulation(Ogre::Vector3(0.0f, 1.0f, 0.0f)); + mAnimation->play(mCurrentGroup, "start"); + break; + case CharState_Dead: mCurrentGroup = "death1"; mAnimation->setAccumulation(Ogre::Vector3(1.0f, 1.0f, 0.0f)); diff --git a/apps/openmw/mwmechanics/character.hpp b/apps/openmw/mwmechanics/character.hpp index c151b3b9fd..f2651b4cfc 100644 --- a/apps/openmw/mwmechanics/character.hpp +++ b/apps/openmw/mwmechanics/character.hpp @@ -16,6 +16,10 @@ namespace MWMechanics enum CharacterState { CharState_SpecialIdle, /* When running a PlayGroup/LoopGroup animation. */ CharState_Idle, + + CharState_WalkForward, + CharState_WalkBack, + CharState_Dead };