This time, I have decided to introduce character animation control. There are several reasons for that. A lot of people asked me to give some example, and at same time, such library will be essential for following AI tutorials, so having said that, I have decided to introduce AI library, so it will be avoided confusion with corresponding command set in AI tutorials. I would like to also make note that all libraries I have released and Im planning to release, are a lite version of fully fledged feature set in game engine Im planning to sell, after my game is out, so all this is some sort of 'advert' what full version can do, in order to make people more interested about system.
Now, lets go back to topic. During game development, one of important roles are game character animations. From programmer standpoint, control of animations must be very simple, much as possible, with same rules applicable to both, gameplay character, as well as NPC's. Even more, it is important to have ability to have character easy 'switchable' between player control or some other system (cut scene manager, AI control, scripted event). So, how is it done in this library?? Very simple. First of all, during design, you will notice that there are always certain animation 'groups'. Animation inside those groups, should fall under same control scheme. Of course, it is entirely possible to have different control scheme for each animation group, but it is NOT advisable. So what are those 'animation groups' ?? Let me explain on provided example. Lets assume that our character has 2 main pose(im not sure is this proper word). In short, lets say that our character can move in normal way (standing up pose) and crouch pose. Each of this poses I call a 'group' . Animations within each group use (should use, but its not necessary), same command set. For example, when character walk while in stand up pose, we use KEY_UP so character animating in WALK animation. When we switch to CROUCH (let say hit button C as usual in games), then SAME command (KEY_UP) will make character animating in WALK animation BUT in crouch pose. Also, while character doesnt move at all, it should be in 'STOP' animation. That animation plays main idle and if player doesnt do anything, system should play some of side idles, if available and after it plays, go back to main idle (like, Lara Croft, bored and play various animations if player doesnt do a thing)..Library giving ability for creation of infinite number of groups and infinite number of animations within groups, so its up to designer/programmer to utilize system properly Library command set is rather simple, and yet powerful, so lets see command set.
'CREATE ANIMATION FOR CHARACTER
CHARACTER = TAnimation.Create("MyCharacter.gmf",IdleTriggerTime:Int=20000)
Its animated character we want to control.
This is time representing how long will be played main idle, before plays one of randomly choosen side idles, if any. So it is time what system will wait player, before switch to one of 'boring' animations. Its exposed in milliseconds, so default value is 20000 what is 20 seconds.
'ADD ANIMATION GROUP('S)
CHARACTER.extract_sequence("ANIMATION GROUP NAME", "ANIMATION COMMAND NAME", firstFrame:Int, lastFrame:Int,playType:Int=CONTINOUS_LOOP, idleType:Int=MAIN_IDLE, transition:Float=0.0, speed:Float=1.0)
This command will extract animation stored in given frame range, under ANIMATION COMMAND NAME and inside ANIMATION GROUP NAME.
ANIMATION GROUP NAME
Thisis name of specific animation group, what will contain specific animations.
ANIMATION COMMAND NAME
This is name of specific animation, what will be used to play specific animation, during gameplay.
First Frame of animation
Last Frame of animation
It is flag representing way animation is played. It should be left in default value (CONTINOUS_LOOP), as other modes are used for internal processing as well as for some other libraries im about to introduce later, during AI lessons. Just for info, available flags are:
But as i said, you SHOULD let it be default value only, as others are used for other things, we will see, later.
This flag tells to system what kind of animation is one to be loaded and therefore, how it will be treated. If animation is MAIN IDLE then flag is MAIN_IDLE. If animation is idle for 'bored' animation, then flag should be SIDE_IDLE. SIDE_IDLE animations are attached to MAIN_IDLE and after idleTriggerTime is elapsed, one of SIDE_IDLE animations will be played and then go back to MAIN_IDLE. If animation is not any kind of IDLE animations, then it should be flagged as NOT_IDLE. This flag will be our, walk, run, jump, die, etc, animations we control. So possible flags for animation types are:
This is value representing transition smoothnes between animations.
This value representing animation speed. Default value is 1.0.
'INITIALIZE ANIMATION SETUP WE WANT TO START WITH
CHARACTER.enable_initial_animation("ANIMATION GROUP NAME", "ANIMATION COMMAND NAME")
This command will basically set choosen animation group as default one and play animation from that group with ANIMATION COMMAND NAME when program starts. Usually used to setup main idle play before game starts.
In order to play some animation in runtime, we use command
CHARACTER.play("ANIMATION COMMAND NAME")
This command has to be called just once and system will play it, long as it is not called any other animation.
During runtime, we want to switch from one animation group, to another. In order to do that, we use this command:
CHARACTER.enable_animation_group("ANIMATION GROUP I WANT TO MAKE ACTIVE")
CHARACTER.play("INITIAL ANIMATION NAME I WANT FROM JUST SELECTED ANIMATION GROUP")
And thats pretty much all. If you wanna free from memory all stuff, during switching levels and what not, just do this:
..and you are freeeeeee... I hope you guys will have some nice use of this library. Stay tuned as MUCH more comming..
Inside zip file is EXE. you can run it in order to see how it works. EXE contain all shaders, dll's, etc so dont put it together with shader folder of yours. Character seen in EXE example, I cant share, but source code of example is kindly provided, so you just play with your own characters. Also, library consider that all animations are stored along ONE frame line, so keep that in mind.
Installation is simple..just copy e1.mod folder in to your Bmax mod folder and you are good to go..
Library available here: