How to lock animation to avoid spamming an action?

In my game I use animation like a kick + collision detection to inflict dmg on another object. As it is now, the player can spam the kick button to kill any object in a sec.

Is there a way to say something like??:

if (animation = notDone)
kick= false

Also would be great if someone could help me out with this problem:
http://hub.jmonkeyengine.org/forum/topic/state-was-changed-after-rootnode-updategeometricstate-call/

Thank you in advance

the gist of what you want to do is

[java]if(!animChannel.getAnimationName().equals(“youranimation”)){
animChannel.setAnim(“youranimation”);
}[/java]

1 Like

^ like whaticamefromspace said. You should have an animation that is “idle” or something that just repeats all the time, and change it to the attack when needed, and set that animation to return to the idle animation when finished. Then you can check if the current animation is the idle one, and if it is, the attack is over.

1 Like

Not sure if I understood the answer correct.

FYI: I have my model always on “Idle” animation when not in action or after finishing an animation.

Is is as simple as saying
[java]
if(!animChannel.getAnimationName().equals(“Kick”)){
animChannel.setAnim(“Kick”);
}
[/java]

Edit: I tried it out. It didn’t help in my case, I think it is due to my Idle state?

excerpt from the code:
[java]
public void onAction(String name, boolean isPressed, float tpf)
{
if (name.equals(Kick))
{
if (!animChannel.getAnimationName().equals(Kick) && isPressed)
{
kick = true;
animChannel.setAnim(Kick);
animChannel.setLoopMode(LoopMode.DontLoop);
}

  }
 else 
 { 
            kick = false;
            animChannel.setAnim("Idle1", 3f);
            animChannel.setLoopMode(LoopMode.Loop);
            animChannel.setSpeed(1f);
 }

}
[/java]

Edit2:
It worked. Thanks!
I had to move the else statement to the onAnimecycleDone and thats was it :smiley:

Regards,
Delly