Search Unity

Attaching animations to events

Discussion in 'Animation' started by denissuu, Jan 22, 2020.

  1. denissuu

    denissuu

    Joined:
    Nov 6, 2019
    Posts:
    162
    Hi there fellow users!

    How could I animate my character and attach the animations to certain events like walking or standing still?
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,565
    Are you asking about Animation Events which let you trigger code at certain times throughout an animation or how to control the animations themselves with basic scripting?
     
    denissuu likes this.
  3. denissuu

    denissuu

    Joined:
    Nov 6, 2019
    Posts:
    162

    I'm just trying to control animations, yes.When he stands still play an idle animation or when he is running he should play the running animation.That's all I want to do for now.
     
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,565
    I recommend you check out Animancer (link in my signature) which has lots of Examples with detailed instructions on how to use it.

    Otherwise just Google something like "how to play animations in Unity" and you'll find plenty of tutorials that explain how to do it with Unity's inbuilt systems.
     
  5. StaticClass

    StaticClass

    Joined:
    Jan 31, 2014
    Posts:
    12
    1) Use Animator Window to setup your character's Animator Controller.

    2) Add parameters (name them as you wish) and then use those parameters to condition how and when a state transitions to other state. For example, in the picture, transition Idle->Run has a condition that checks if Speed parameter is greater than 0. If that's true, the transition will happen.

    3) Update your Parameter values via script using Animator methods like SetBool/SetFloat etc.