Here, we will use the same code that we used for creating the first example:
Change the animation from
Dance
toRunBase
._aniState = _ent->getAnimationState("RunBase");
Run and compile the application. You should see Sinbad running, but only with the lower half of his body.
For our second animation, we need a new pointer for the animation state:
Ogre::AnimationState* _aniStateTop;
Then, of course, we need to get an animation for this state, enable it, and loop it. The animation we want to get is called
RunTop:
_aniStateTop = _ent->getAnimationState("RunTop"); _aniStateTop->setEnabled(true); _aniStateTop->setLoop(true);
The last thing to do is to add the passed time to this animation, like we did for the first one:
_aniStateTop->addTime(evt.timeSinceLastFrame);
Then again run and compile the application. Now you should see Sinbad running with his whole body.