playMaker

Author Topic: Complex animation graph setup theory question  (Read 6431 times)

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Complex animation graph setup theory question
« on: June 20, 2011, 08:57:59 PM »
I'm working on building a set of movments/attacks in playmaker and wanted to ask a bit about the theory of setting up a complex animation graph.

Would it be a good idea to start with a state called "movement" for example, which has various types of transitions depending on the type of movement the player is trying to perform?

eg:
STATE: Moving
transition: walking
transition: running
transition: crouching
etc etc...

Then each of those would branch out and your animation's for Shooting would change depending on which movement state you were in?  therefore you'd have seperate animations for walking while shooting/ running while shooting etc etc...

That part i want to get clarified on, is that if you can only ever be in one "state" at a time, how do you combine actions together?  each need their own set of animations?  if so, how would the graph look like for example?

thx

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Complex animation graph setup theory question
« Reply #1 on: June 20, 2011, 09:12:59 PM »
is it going to end up having different moving states looking like this??? (unreal 3 anim tree)



Xtopher

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 71
    • Well Played Games
Re: Complex animation graph setup theory question
« Reply #2 on: June 23, 2011, 08:55:11 PM »
Your pulling on a thread here...   ;)    Animation graphs can get complex really fast, but they don't have to be hard to deal with.

You want to have your base state be an "idle".  This is what your character does when the player does nothing... no input, no game script acting on it, no physics forces, nothing.  It just stands there and breathes, looks around, whatever. 

Off of the idle you can look for player input and then blend into "walk", "run", "jump", "crouch", states, depending on your game needs.  Walk/Run is usually based in one of two ways... the full range of player input from something like a thumbstick would be mapped to walk/run states based on speed.  Anything above/below causes a switch, with an anim blend in between.  Another option is a hard button check... "W" means walk, and "Shift" means run.  Also, you can often get away with blending from an idle into a walk, but sometimes you will need a specific "start walk" and "stop walk" anim for the transition.

Now here's the complexity... in our W/Shift example... that's two states (nodes).  In the W state, you need exit events for "go to idle" and "run", because the player will either stop, or go faster.  Going to the idle is done by releasing the W key, and going to run is done with the Shift key is pressed.  Be sure to set up the wiring so that run happens even if W is still being held, because that would be the common player behavior.

The shifts between idle/walk/run should start to illustrate where the complexity starts.  What if you have jump in your game?  Can I jump while walking?  If so, the walk state needs and exit to jump.  And what happens when you land?  Your jump state needs to check what the player is doing, because we could be going go back into a walk, we could have pressed Shift because we want to run, and we might have taken our hands off the controls completely, which would lead to going back to idle.  Some of these will blend nicely together, others will need transition animations.  (I STRONGLY advise you to try as hard as possible to minimize the amount of animations your character needs!)

I hope that gave you enough to get started.  I suggest starting really basic and building up as you need it, rather than trying to build something huge to begin with.  The average console game character could have a couple hundred animations!  Don't go there!  Just start with two or three states, get comfortable working through them, and then you will be ready to start adding more functionality to your character. 

Have fuN!


artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Complex animation graph setup theory question
« Reply #3 on: July 14, 2011, 04:57:56 PM »
I hope this conversation isn't too old to add to. 

I'm doing something similar to this as I bring my project closer to a polish state.  I had read in some of the documentation or comments (I forget where), where Alex recommended relying on animation clips to drive transitions between states, since animations were time-oriented by nature.  I've tried basing my graphs around this idea, but I have states that will skip ahead and perform their actions while the preceding animations are still playing. 

Example: I have a throwing mechanic in my project.  The player presses a button and throws a ball.
I want the ball to be created only at the end of the throw animation.  I used a PlayAnimation action with a specific Finish Event, under the impression that the animation would finish playing before kicking off the Event.  In the state following the animation state, the ball is spawned and thrown.  If the player mashes the throw button repeatedly though, the throw animation will only play sometimes, while a ball is thrown after every button press. Why is this?

Thanks for any help.  I was going to post up my graphs when I'm done, if you think it would help. 

Justifun - how far along are you in your project?  Just asking since this thread is a month old.



justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Complex animation graph setup theory question
« Reply #4 on: July 14, 2011, 05:12:22 PM »
Artician, I think you can achieve what you want with the ball throwing issue, by removeing the animation event, and simply use a "on finished" for your play animation action, and have your next state be the ball creation state. 

This way it should play the whole animation no matter what, then spawn the ball and launch it.  And it shouldnt spawn another ball/animation until the FSM gets back to the "waiting for player input" section.

If you have a "finishing the throw" animation that's playing right after the initial windup animation, make sure that blend time is set to 0 so that it doesnt skip any of the animation and possibly go back to the "ready to throw" state too quickly.

My project is still in development, but its getting there.  I'm planning on doing a screencast shortly outlining the way i set up my animation graph etc, but i havent found the time yet.


artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Complex animation graph setup theory question
« Reply #5 on: July 14, 2011, 05:27:31 PM »
Thanks very much for the suggestion.  I'll try it and post back.  My projects animations are tied directly to gameplay, so here's hoping it works out the way I expect!  Thanks for the tip on the blend time as well, that would have definitely got me.

EDIT - actually, it was the blend time that was screwing me up.  That little .3 value was enough to cause a cascade of events.  Setting it to 0 fixed the issue entirely.

Additionally, from the PlayMaker documentation I got this confirmation as well:
Quote
Finish EventEvent to send when the animation finishes playing.
https://hutonggames.fogbugz.com/default.asp?W19

So I was right in using the Finish Event field within the animation component too.  It was just the blend time in the end.

Thank you again.

« Last Edit: July 14, 2011, 05:33:58 PM by artician »

Xtopher

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 71
    • Well Played Games
Re: Complex animation graph setup theory question
« Reply #6 on: July 14, 2011, 07:40:55 PM »
Quote
If the player mashes the throw button repeatedly though, the throw animation will only play sometimes, while a ball is thrown after every button press.

I may be reading this incorrectly, but this sounds like an issue you want to trap.  Generally you want to kill the opportunity for player input the instant they press a button (or whatever) to prevent cascading issues.  For instance, have a listener node that waits for input from the player to throw.  Upon getting that, immediately leave that node and go to a new one that handles all the actions, and does not accept player input of any kind.  That will ensure that the input event only occurs once, and your events happen the way you want.  This should be a general rule of thumb applied to everything you set up in any game.

Sorry if I misunderstood that part of your statement! 

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Complex animation graph setup theory question
« Reply #7 on: July 14, 2011, 07:47:25 PM »
Glad you figured it out artician, from all the posts about your game, im looking forward to seeing the final product!

If you need a beta tester, plz let me know :)


artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Complex animation graph setup theory question
« Reply #8 on: July 14, 2011, 08:44:22 PM »
Sorry if I misunderstood that part of your statement! 

No, that is the best help yet!  Thank you very much!   You've basically outlined exactly what I needed to do, but I lack the knowledge and terminology. 

I ran into trouble when I began needing conditional input.  I have a very simple context-based interaction, so pressing a key while doing  X gets a different reaction than holding the same key while doing Y.  I know that's an incredibly general description, but if you have any further tips for things like that, please share! 

Quote
If you need a beta tester, plz let me know

I would estimate I have between 3-6 months left of development time.  Depending on how things go, that could include testing time.  Either way, I am *really* going to need help on that end, as I haven't given it much thought yet, and this would be my first, truly independent game.  I will certainly keep you in the loop.  :)

Thanks again!


justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Complex animation graph setup theory question
« Reply #9 on: July 14, 2011, 09:09:25 PM »
Quote
Generally you want to kill the opportunity for player input the instant they press a button (or whatever) to prevent cascading issues.  For instance, have a listener node that waits for input from the player to throw.  Upon getting that, immediately leave that node and go to a new one that handles all the actions, and does not accept player input of any kind. 

I've been playing around with some ideas along the line of this in my head and wanted to see if you had any further suggestions...

For example.  If a player mashes a "punch" button rapidly in succession.  Would you expect them to execute the same number of punches that the amount of times the button was pressed?  or only once per "punch" animation, and therefore probably executes a less number of punch animations because the next button press would occur while the first one was still taking place.  I guess its just preference. 

I've been thinking of "attack combos" eg: punch punch kick, vs punch kick punch etc etc.

One way i tried setting it up was having the punch animation play along with a "get punch button" action which would take you to the next punch variation....again with another "get punch button " action and finally leading to a get kick button action.  (all with a finished transition that goes back to the idle state should the player not press anything)

The problem with this, is that if you hit the punch button a second time while the first punch is still playing, it aborts that animation mid play (if you have stop all animations checked) and plays the second.  This can be pretty jaring visually (especially if your punch animation is very long).

The other idea i had was to put a "wait" action in a state immediately after the "play animation" state, equal to the length of the animation currently playing.  This way if the player hits punch again while the first one is playing, it jumps to the next state(waits 2 seconds) then goes to play punch 2 and the first punch finishes completely.  The problem with this meathod is that you might have hit the punch button like 5 times before the first punch animation finishes, and then just feels "off".

My third solution which i havent tested yet but might work smootly and responsivly is to break down each attack animation into a beginning half and a ending half.

State 1:
Play beginning half of punch
Get Punch Button action -> play punch 2 state
finished - > play second half of punch -> goto idle

state 2:
(Tweak animation so that it starts the animation from mid punch 1 instead of from idle)
Play beginning half of punch 2
get punch button action - > play punch 3 state
get kick button action -> play kick action
finished - > play second half of punch -> goto idle


Any other ideas how this could be setup?

I was thinking of maybe doing something (and im not sure how without arrays).... but to check for all user attacks within the last second.  queue them up and then execute them one after another.  So if they mash punch/punch/kick/punch/kick....it would hold onto them for a brief second, and then unleash a fury of attacks.  If no input is registered for a second afterwards, it would reset to being a blank queue.

Jaelaea

  • Playmaker Newbie
  • *
  • Posts: 1
Re: Complex animation graph setup theory question
« Reply #10 on: June 21, 2012, 09:56:38 AM »
Quote
Generally you want to kill the opportunity for player input the instant they press a button (or whatever) to prevent cascading issues.  For instance, have a listener node that waits for input from the player to throw.  Upon getting that, immediately leave that node and go to a new one that handles all the actions, and does not accept player input of any kind. 

I've been playing around with some ideas along the line of this in my head and wanted to see if you had any further suggestions...

For example.  If a player mashes a "punch" button rapidly in succession.  Would you expect them to execute the same number of punches that the amount of times the button was pressed?  or only once per "punch" animation, and therefore probably executes a less number of punch animations because the next button press would occur while the first one was still taking place.  I guess its just preference. 

I've been thinking of "attack combos" eg: punch punch kick, vs punch kick punch etc etc.

One way i tried setting it up was having the punch animation play along with a "get punch button" action which would take you to the next punch variation....again with another "get punch button " action and finally leading to a get kick button action.  (all with a finished transition that goes back to the idle state should the player not press anything)

The problem with this, is that if you hit the punch button a second time while the first punch is still playing, it aborts that animation mid play (if you have stop all animations checked) and plays the second.  This can be pretty jaring visually (especially if your punch animation is very long).

The other idea i had was to put a "wait" action in a state immediately after the "play animation" state, equal to the length of the animation currently playing.  This way if the player hits punch again while the first one is playing, it jumps to the next state(waits 2 seconds) then goes to play punch 2 and the first punch finishes completely.  The problem with this meathod is that you might have hit the punch button like 5 times before the first punch animation finishes, and then just feels "off".

My third solution which i havent tested yet but might work smootly and responsivly is to break down each attack animation into a beginning half and a ending half.

State 1:
Play beginning half of punch
Get Punch Button action -> play punch 2 state
finished - > play second half of punch -> goto idle

state 2:
(Tweak animation so that it starts the animation from mid punch 1 instead of from idle)
Play beginning half of punch 2
get punch button action - > play punch 3 state
get kick button action -> play kick action
finished - > play second half of punch -> goto idle


Any other ideas how this could be setup?

I was thinking of maybe doing something (and im not sure how without arrays).... but to check for all user attacks within the last second.  queue them up and then execute them one after another.  So if they mash punch/punch/kick/punch/kick....it would hold onto them for a brief second, and then unleash a fury of attacks.  If no input is registered for a second afterwards, it would reset to being a blank queue.

How about setting it up so that the succeeding attacks of a combo are triggered based on the animation frames. So it would only be possible to start the second move of a combo only if it was pressed within a specific frame window of the previous move.