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

Switch state when one of two triggers is triggered

Discussion in 'Animation' started by HeaDiii, May 17, 2016.

  1. HeaDiii

    HeaDiii

    Joined:
    May 18, 2015
    Posts:
    60
    Hey there,

    in my AnimationController i have an Animation that should transition to another Animation as soon as one of two possible triggers is activated. How do i do that?

    Right now both triggers have to be activated to make the transition work.
     
  2. TrickyHandz

    TrickyHandz

    Joined:
    Jul 23, 2010
    Posts:
    196
    If I understand correctly, what you currently have is a single transition with two conditions. This set up operates like a logical AND operator, i.e (trigger1 && trigger2) where both triggers must be true.
    To get the behavior of a logical OR operator, i.e. (trigger1 || trigger2) where only one is required, you will need to create a second transition from State1 to State2. Add the second transition the same way you added the first one and you will notice the connection between the states now has multiple arrows, this lets you know there are two or more transitions. Each transition can have its own set of conditions on it.
     
    Baste likes this.
  3. HeaDiii

    HeaDiii

    Joined:
    May 18, 2015
    Posts:
    60
    Thanks, this is what i wanted to know.
    I already tried to set up the double transition with the multiple arrows but it was still acting like before (Trigger1 && Trigger2).
    I'm going to Post a Screenshot as soon as i get home today.
     
  4. HeaDiii

    HeaDiii

    Joined:
    May 18, 2015
    Posts:
    60
    Alright, here is the screenshot.


    Am I missing something?
     
  5. TrickyHandz

    TrickyHandz

    Joined:
    Jul 23, 2010
    Posts:
    196
    It looks like you still have two conditions on a single transition. When you select the line that has multiple transitions, you can switch which transition you are manipulating using the list in the top of the inspector on the right. Make sure the condition list at the bottom of the inspector only has one condition in the list. After that, you should get the desired effect.
     
    HeaDiii likes this.
  6. HeaDiii

    HeaDiii

    Joined:
    May 18, 2015
    Posts:
    60
    Alright alright, it works ;)
    I didn't know i had to select the transitions in the inspector after selecting the Line.

    Thanks man :)
     
    TrickyHandz likes this.
  7. TrickyHandz

    TrickyHandz

    Joined:
    Jul 23, 2010
    Posts:
    196
    You're very welcome! Glad it is all fixed up for you now.