Walk animation

i'd like to make walk animation that can move forward and backward. i Have animation with frame composition like this:


  • walk forward=frame 3-28

  • stand = frame 1

  • transition from stand to walk= frame 2


I hope to make my animation can work with this capability:

  • It can be controlled by button with AllowsRepeats=true

  • when button ( for instance "button W") is pressed once it will move forward. Then after finish it will stand again

  • BUt when i press button continuesly it will move continuesly without stand at transition
  • [li]

for this purpose i have done same trial and error and have successed move continuesly when i hold button. BUt i still confuse What should i do to make animation play one step then back stand when i press button once. How does detect if button pressed repeated or NOt?


The way I did it in my app with the mouse button was:


  • Check in update if mouse is pressed.

  • IF Mouse is pressed and flag is NOT set, set up flag that mousebutton is pressed

  • IF Mouse is NOT pressed and flag is SET, unset flag.



There are probably built in methods of doing this, but it suited my purpose well and was foolproof.

One additional thing though - perhaps you should consider making the 'stand' animation also more than 1 frame - it would make the scene look more alive if the entity moves a bit when standing still - look around or whatever.

heh, yeah and its always fun to watch the idle animations in games like tf2 for example.

:-)Thank for the ideas.

I just detect button and is it press or release.But in my code there are two action to detect press or release. It's my code :


         public void performAction(InputActionEvent evt) {
            // TODO Auto-generated method stub
            super.performAction(evt);
            if(evt.getTriggerPressed()){
               if(evt.getTriggerIndex()==KeyInput.KEY_NUMPAD8){
                  player.moveType=Characters.WALK_FORWARD;                                 
               }               
               if(evt.getTriggerIndex()==KeyInput.KEY_NUMPAD5){
                  /*walk backward*/
                  player.moveType=Characters.WALK_BACKWARD;
               }               
               if(evt.getTriggerIndex()==KeyInput.KEY_H ){
                  /*hit enemy*/
                  player.moveType=Characters.HIT_ENEMY;
               }               
               if(evt.getTriggerIndex()==KeyInput.KEY_F){
                  /*defend*/
                  player.moveType=Characters.DEFEND;
               }         
               if(evt.getTriggerIndex()==KeyInput.KEY_R){
                  /*defend*/
                  player.setAngleRotation(player.getAngleRotation()+0.05f);
                  player.setLocalRotation(new Quaternion().fromAngleAxis(player.getAngleRotation(), new Vector3f(0,1,0)));               
               }
               if(evt.getTriggerPressed())
                  player.pressed=true;
            }               
         }                     
      };
      
      keyAction buttonRelease = new keyAction(){
         @Override
         public void performAction(InputActionEvent evt) {
            // TODO Auto-generated method stub
            super.performAction(evt);
            if(!evt.getTriggerPressed())
               player.pressed=false;
         }
      };
      [b]  input.addAction( actionKey1, InputHandler.DEVICE_ALL, InputHandler.BUTTON_ALL, InputHandler.AXIS_NONE, true );
input.addAction( buttonRelease, InputHandler.DEVICE_ALL, InputHandler.BUTTON_ALL, InputHandler.AXIS_NONE, false );[/b]


i see that :

  • if allowsRepeats is given true BUtton can press repeatly but can't detect wheter pressed or release.

  • if allowsRepeats is given false BUtton can't press repeatly but can detect wheter pressed or release.


But it's work well in my code.