Search Unity

Stop Animation from Automatically Playing?

Discussion in 'Animation' started by SprinkledSpooks, Jul 20, 2016.

  1. SprinkledSpooks

    SprinkledSpooks

    Joined:
    Jun 1, 2016
    Posts:
    117
    I'm new to animating in Unity and I just recently made my first animation in which a door slides open. However, now this animation plays automatically before I can use a script to trigger the animation. How would I go about disabling the ability for this animation to play automatically?
     
    chorosunmark likes this.
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    Using the Animator component: create a state with no animation in it, and set that as the default state.

    After that, you can either
    * add a transition between your new empty state and your animation that depends on a trigger parameter
    * call Animator.Crossfade to start your state
     
  3. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    I get what you're saying and this is exactly what I'm looking to do. However, I don't fully grasp adding the parameters. I created a trigger and named it "Start" because I want it to start my animation. However, I don't know how to put this to use.
     
  4. AvaSpa

    AvaSpa

    Joined:
    Dec 28, 2016
    Posts:
    1
    This doesn't seam to work. In my case it keeps looping the empty state and doesn't give control to my game logic.
    I have some game logic that translates and rotates my player. And that doesn't run because the empty state keeps looping.
     
  5. Angad_Basandrai

    Angad_Basandrai

    Joined:
    Dec 23, 2020
    Posts:
    1
    In a script have the animator assigned and use "variablenameforanimator.SetTrigger("Start");"