Sign in to follow this  
Followers 0
  • entry
    1
  • comments
    11
  • views
    3,689

Character Animation Control

Sign in to follow this  
Followers 0
Naughty Alien

2,691 views

blog-0077503001331131865.jpgThis 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' smile.png. 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 smile.png Library command set is rather simple, and yet powerful, so lets see command set.

 

'CREATE ANIMATION FOR CHARACTER

CHARACTER:Tanimation

CHARACTER = TAnimation.Create("MyCharacter.gmf",IdleTriggerTime:Int=20000)

 

MyCharacter.gmf

Its animated character we want to control.

 

IdleTriggerTime:Int=20000

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.

 

firstFrame

First Frame of animation

 

lastFrame

Last Frame of animation

 

playType

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:

 

-CONTINOUS_LOOP

-ONE_LOOP_THEN_IDLE

-ONE_LOOP_THEN_STOP

 

But as i said, you SHOULD let it be default value only, as others are used for other things, we will see, later.

 

idleType

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:

 

-MAIN_IDLE

-SIDE_IDLE

-NOT_IDLE

 

transition

This is value representing transition smoothnes between animations.

 

speed

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:

 

CHARACTER.Free()

CHARACTER=Null

 

..and you are freeeeeee... smile.png I hope you guys will have some nice use of this library. Stay tuned as MUCH more comming..

 

NOTE:

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:

http://www.leadwerks...ion-libraryzip/


3
  Report Entry
Sign in to follow this  
Followers 0


11 Comments


hey MG, thanks man..later ill show how this library can automatically make character play certain animations during crossing over specific obstacles..like, you running, then small wall is in front of your character and once close enough suddenly, character plays jump over wall animation and continue running as it was before wall.. :( .. many features available..

2

Share this comment


Link to comment

hey MG, thanks man..later ill show how this library can automatically make character play certain animations during crossing over specific obstacles..like, you running, then small wall is in front of your character and once close enough suddenly, character plays jump over wall animation and continue running as it was before wall.. :( .. many features available..

oooo sounds nice NA...

0

Share this comment


Link to comment

What is the source of the character you are using for your demo? I want to quickly test it, don't mind if I have to buy it somewhere.

0

Share this comment


Link to comment

hey MG, thanks man..later ill show how this library can automatically make character play certain animations during crossing over specific obstacles..like, you running, then small wall is in front of your character and once close enough suddenly, character plays jump over wall animation and continue running as it was before wall.. wink.png .. many features available..

 

 

Cool, sounds like something to look forward to trying m8 .. I am all in favour of things that save me having to write them .. I am also in favour of gorgeous voluptuous scantily clad women who dable in the dark arts and do magic .. but thats another story ... dont want to upset Roland ... lol

0

Share this comment


Link to comment
What is the source of the character you are using for your demo? I want to quickly test it, don't mind if I have to buy it somewhere.

 

..character is Heru, main character from my game Hidden Dawn..character u saw is actually LOD2 level, and because its going to be used in one of my games, I couldnt share it, not that im stingy :(

 

Next library is controller control library, what will be blended with existing one. After that, everything will be ready for AI tutorials.

0

Share this comment


Link to comment

Cheers, count me in as a customer for this library. After reading (and re-reading) it sounds ideal. The remaining hard part is then writing the control logic. Going from a prone to a kneeling state, then aiming, that sort of thing.

0

Share this comment


Link to comment

..full version will introduce very easy logic setup for all controls, switching, speed of animation casted over to controller, automatic animation play when character moves over certain obstacles (like you are running and small wall appear, then system will automatically play animation of jumping over with adjustment of controller), cut scene manager with auto sync with sound, etc..

0

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Create Your Account

Sign in

Already have an account? Sign in here.


Sign In Now