Hello… Sorry for my bad english.
Im facing some animation problems in my c++ panda3d school assignment.
I tried to load animations using the ‘Roaming-Ralph in C++’ method. the Blackie used is just a renamed Ralph.egg (from Ralph.egg to Blackie.egg).
/*In a loading function*/
charModel[RALPH].modelFileName = "Characters/Blackie/Blackie";
charModel[RALPH].runAnimFileName = "Characters/Blackie/ralph-run";
charModel[RALPH].jumpAnimFileName = "Characters/Blackie/ralph-jump";
/*In a init function for individual characters*/
_characters[charId]->model = _WindowFramework->load_model(_WindowFramework->get_render(),charModel[charType].modelFileName);
_WindowFramework->load_model(_characters[charId]->model,charModel[charType].runAnimFileName);
_WindowFramework->load_model(_characters[charId]->model,charModel[charType].jumpAnimFileName);
auto_bind(_characters[charId]->model.node(),_characters[charId]->ModelAnimControl, PartGroup::HMF_ok_part_extra | PartGroup::HMF_ok_anim_extra | PartGroup::HMF_ok_wrong_root_name);
then i tried to play the ‘Run’ animation when user is ‘Running’ and the ‘Jump’ animation when user presses spacebar.
if((_characters[iter->first]->Move_Forward || _characters[iter->first]->Move_Backward
|| _characters[iter->first]->Move_Left || _characters[iter->first]->Move_Right)
&& !_characters[iter->first]->Jump && !_characters[iter->first]->playJumpAni)
{
_AnimationFSM.EnterRun(_characters[iter->first]);
}
else if (_characters[iter->first]->playJumpAni && _characters[iter->first]->Jump)
{
_AnimationFSM.EnterJump(_characters[iter->first], charModel[_characters[iter->first]->id->type]);
}
and then i tried to play the animation according to the keypresses.
BUT, when i tried to play animations using the keypresses, SOMETIMES, the animation plays the wrong file, eg. plays the ‘Jump’ during running or plays the ‘Run’ during jumping.
I checked through my logic and i find nothing seriously wrong with it (the changing of boolean variables are not difficult), so i dont think there’s any error with the logic.
This is how i play the animation during the different key presses:
void AnimationFSM::EnterRun(Characters *_Characters)
{
if (_Characters->id->type == RALPH)
{
cerr<<"******MOVE*********"<<endl;
_Characters->ModelAnimControl.loop("Ralph", false);
}
}
void AnimationFSM::EnterJump(Characters *_Characters, CharDefaults _CharModels)
{
if (_Characters->id->type == RALPH)
{
cerr<<"******JUMP*********"<<endl;
_Characters->ModelAnimControl.loop("Ralph.1", false);
if (_Characters->ModelAnimControl.get_frame("Ralph.1") == 13)
{ _Characters->ModelAnimControl.pose("Ralph.1",13); }
}
}
when i do the key presses, the text printed on the console is correct, eg printed “MOVE***” when i move around, and “JUMP***” when i presses spacebar even though the animations played are wrong.
i need urgent help in finding the solution to this problem and it will be best if there are some simple examples of playing multiple animations through key presses in C++ OR detailed documentations.
thanks in advance to all who are willing to help me