Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

When and why to use Animation.Play() ?

Discussion in 'Scripting' started by rahulnaik9010, Aug 28, 2020.

  1. rahulnaik9010

    rahulnaik9010

    Joined:
    Jan 2, 2019
    Posts:
    19
    Hey guys!
    Is there any disadvantage of using Animator.Play() ? Instead of using triggers,booleans why can't i simply use Animator.Play() ?
     
    Last edited: Aug 30, 2020
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Triggers and booleans are for manipulating the state machine of an animator.

    Animation.play and Animator.play are also different things. But i believe animator.play pretty much does an end-run around the state machine and forces a particular animation to play directly. It won't obey the rules of transitions etc like the other methods do.
     
    eses likes this.
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,355
    Animation.Play will simply play an animation, but if you use an Animator to control your animations instead then you can set-up transitions between each animation state and it will smoothly blend between them.
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,741
    One note: It's important to recognize the difference between the Animation and Animator classes. Animator is the modern system, and Animation is the legacy system, no longer maintained. If you're not working on a project that dates back to 2014ish, don't use Animation.
     
  5. rahulnaik9010

    rahulnaik9010

    Joined:
    Jan 2, 2019
    Posts:
    19
    Hey I changed the question....Thanks
     
  6. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Nobody is stopping you. You just won't get the benefits of the state machine controlling transitions etc.