Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Using seperate states for things like combat/none combat

Discussion in 'Animation' started by Archania, Aug 29, 2013.

  1. Archania

    Archania

    Joined:
    Aug 27, 2010
    Posts:
    1,662
    I was wondering if anyone has had luck with having different states for characters that wouldhave anon combat/ combat states. How do you handle the run, walk etc animations.
    Are you using a mask and keep the same animations or if the character has separate animations for combat use them?
    Just looking for best practices and ways to do it.
     
  2. ShadowOfTheBeast

    ShadowOfTheBeast

    Joined:
    Apr 8, 2013
    Posts:
    13
    good question I am also looking into this so far the best thing to do is study how other good games do it for example I am looking at a 3rd person adventure fighting game like batman and analysing how my Xbox controller is mapped to all his abilities walking running jumping and the fighting
    I dont think having a separate Layers for normal mode and a separate layer state for fighting mode...
    it should be a combination of transitions for example when he is in and idle state he is standing if I press 'x' on my controller nothing happens but if I transition into walking mode and press x then he would punch!

    something like this but I think if you do the above as well as study the Layer states in the mecanim video like above you will get it.good luck!
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    I currently use animation layer syncing in Unity Pro to switch between non-combat, pistol combat, and rifle combat states. The active state's layer weight is 1, and the other layers' weights are 0 so they don't get processed. (Except for changing states, when I lerp weights from one layer to another to provide a smooth transition.) I have a set of layers for lower body state and a parallel set of layers for upper body state.

    With layer syncing I can use the same parameters (speed, direction, fire, etc.) generically without worrying about what state the character is in, and changes propagate to all synced layers (I only need to assign state-specific animations). A separate animation logic controller sits on top of Mecanim to provide a higher level abstraction between Mecanim and my character action controller.

    ----

    In a different project that needs to support Unity Free (i.e., no sync layers), I put each combat state (non-combat, pistol, rifle) in a separate state machine. The top level of layer 0 only has state machines for each of the combat states, so it looks very simple. Inside each combat state machine is the full deal -- movement, shooting, etc. -- each as sub-state machines.

    Again in this project I have separate layers for lower and upper body.

    I used the same character action controller and simply adjusted the animation logic controller to work with this new Mecanim animation state machine. So no changes necessary for the character action controller and everything above that such as AI and navigation.

    I glossed over some details, such as additional layers for additive animation and head control. Facial expressions, however, are controlled by FaceFX-generated legacy animations; I run those through the legacy Animation component on the facial bones only.

    I'm curious to see how others are using Mecanim, too!
     
  4. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Thanks Tony for this and the other message on this board about using sync. I think it has been the most helpful conceptual information on using sync layers that I have yet encountered. Considering how little information there is out there on actually utilizing mecanim I would love to hear any other tips you have to give and if you have a blog or anything please link to it.
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    No blog, just trying to get the job done with Mecanim like everyone else. :)

    Heikki Tormala wrote on Gamasutra about his experience building AirBuccaneers with Mecanim in Unity 4.0. If I recall correctly, this was before sub-state machines, leading one commenter to write: "That movement and steering FSM is terrifying!" But all in all it's a good real world article about Mecanim:

    http://www.gamasutra.com/blogs/HeikkiTormala/20121214/183567/
     
    bowserscastle likes this.
  6. Carl-Gran

    Carl-Gran

    Joined:
    Jul 13, 2015
    Posts:
    12
    I'm having high hopes for the new Playables API. With it you can blend between 2 different controllers, which makes it nice and clean to separate out different logic for things like combat vs. non-combat. Haven't been able to make it work in 5.2.0f3 though :(