Changing animations during the game loop

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Sparrow
Posts: 10
Joined: Mon Jul 02, 2012 4:14 pm

Changing animations during the game loop

Post by Sparrow »

Hi, I hope you guys can help me as fast as you did last time, I really appreciated it.

I am using the Sydney md2 model in my program, and although setting the animation outside the game loop (in main) will play that animation (like EMAT_RUN) when I want to change the animation in the device run loop along with a button pressed, the animation is stuck on the first frame of the new animation (probably because it keeps calling a reset of the animation on each loop).
How would I go about switching between the EMAT_RUN and EMAT_STAND animations on key strokes?
Sparrow
Posts: 10
Joined: Mon Jul 02, 2012 4:14 pm

Re: Changing animations during the game loop

Post by Sparrow »

Ok, I've tried to set flags to keep track of which ones are already playing, but so many flags just become a huge mess, can someone please show me how they make one character do different animations on the click of a button?
irrcode
Posts: 17
Joined: Thu Jun 21, 2012 9:45 pm

Re: Changing animations during the game loop

Post by irrcode »

You could just have an enum and set it to the current animation. You could even throw that into a struct or class to keep one per animated object.
Sparrow
Posts: 10
Joined: Mon Jul 02, 2012 4:14 pm

Re: Changing animations during the game loop

Post by Sparrow »

Thanks, I'll look into that, but could you expand on how this would work?

* Ok, now I've learnt a new thing, enums, thanks! It works now. I'll just put this here for someone who finds this thread:

It seems an enum is a variable you can set, like any, but instead of 1 ,3789, 29 or a, d, or any other letter, you give the variables it can be names. Like in my case I have an enum I called Animation. Animation can be set to RUN, WALK, STAND or HIT, and so if I want to switch to one animation or another, I just check if animation is the one I want to set it to, and then ignore if it's already on that animation. This stopped me from using a boolean flag for each animation state.
Post Reply