Implement WalkForward and WalkBack character states

actorid
Chris Robinson 12 years ago
parent e33f59e0fe
commit aecfc0829a

@ -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);
}

@ -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));

@ -16,6 +16,10 @@ namespace MWMechanics
enum CharacterState {
CharState_SpecialIdle, /* When running a PlayGroup/LoopGroup animation. */
CharState_Idle,
CharState_WalkForward,
CharState_WalkBack,
CharState_Dead
};

Loading…
Cancel
Save