Animation Selection

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
ravenger
Posts: 3
Joined: Thu Nov 09, 2006 12:58 pm
Location: Netherlands

Animation Selection

Post by ravenger »

Im working on a game at the moment (im currently using Irrlicht.NETCP which is awesome and more complete than the official irrlicht.net one), and i have a character which a want to move by pressing left or right. Now when i press left or right, i want to set a certain animation to fit the action corresponding with the moving. So lets say my character walks when i press left or right, i want to have the walking animation shown.

In Ogre its quite simple, since ogre has got an animationState object attached to the entity which contains the mesh. What you do in Ogre is something like this, though you have to stop the animation, then set it, and then start it again (it just continues where you stopped it).

Code: Select all

pseudocode:

while(running) { 
    ... (lots of code)
    // key handling
    if(leftPressed)
        node.setAnimation("Walk");
    } else {
        node.setAnimation("Stand");
    }
}
But in Irrlicht this just isnt possible since everytime you call setAnimation it resets to frame 0 of the sequence. (Or im i wrong?) How could i solve this in a decent way in Irrlicht?

(I could make a state enumeration and wrap a animatedscenenode into a new object; keep track of which is the current state and then i could have a setState function where i could check in which state im currently at and then if needed switch states and animations, but are there alternatives?)
Post Reply