Author Topic: [TUT-ADV] Animation State Machines  (Read 1107 times)

Offline Kad_Venku

  • Administrator
  • Senior Lt.
  • ******
  • Posts: 85
[TUT-ADV] Animation State Machines
« on: May 22, 2017, 03:16:17 pm »
About
In response to a question posted on the YVaW ModDB page I decided to create a short tutorial on how to use the B-Wing animation state machine which is included in our free-released B-Wing pack to your advantage.
This example assumes, that you have a basic understanding about programming (preferable lua) or have the will to dive into the code and examine it.
The code is heavily commented and should together with this text provide enough insight to enable you to re-use the base code and adopt it for your unit.

1. Animation State Machines
Useful links:
To gather a basic understanding of state machines refer to the linked Wikipedia article.
A more specific version of such a state machine is used in almost every game engine to manage animation states and transitions between animation states.
So a very simple example would be this:
Code: [Select]
[[State: "Standing"]] ---------- Play: "sitting_down_animation" ----------> [[State: "Sitting"]]
I've emulated a similar behaviour for the B-Wing with the script provided in the download.
All this script does is evaluating the current state of the B-Wing (In combat or out of combat) and playing different animations depending on the state.

2. Using a similar technique to expand unit behaviour in EaW
The technique provided can be expanded or altered to react to different states of the unit, e.g. whether it is deploying fighters or is under attack, took damage etc. ... all valid animation names (so only names which are being used in the game) can be played from the script. I personally am using the deploy and undeploy animations, and give them numbers to use a nearly unlimited amount of animations. The details on this are explained in the provided code.

3. Advantages and disadvantages of this approach
Advantages:
  • Allows a mod maker to have a unit react to certain events (like deploying/undeploying the S-Foils if engaging combat mode)
  • Allows for more diversity, and provides an overall visual gain.
  • All normal unit behaviour is kept intact, a unit is still able to maneuver, shoot and do everything it normally does.
Disadvantages:
  • It is a scripted system which has to run updates in an regular interval, thus will put additional stress on the game.
  • The script has to be applied to the object, it cannot be applied to the squadron unless you want the hole squadron behave indentically on all occasions.

4. Summary:
Whilst certainly providing a unique feel for a unit and giving it a "nice touch", the system, if overused, will affect performance at one point or another, so you as mod maker will have to decide whether it's worth it to you personally to have this feature running. If you have enough overhead, go ahead and use it, if you're already experiencing performance issues, stay away from this system.

It certainly should not be used to expand the animation behaviour of all fighters in a squadron, not only would adding flight maneuvers to a fighter make them behave unpredictable and lead to immense clipping and graphical glitches, but it would certainly affect performance in a noticeable way.
« Last Edit: May 22, 2017, 03:18:05 pm by Kad_Venku »

Offline Kad_Venku

  • Administrator
  • Senior Lt.
  • ******
  • Posts: 85
Re: [TUT-ADV] animation State Machines
« Reply #1 on: May 22, 2017, 03:16:41 pm »
---- reserved for future additions ----