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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Get if Trigger is set or is a condition of a state

Discussion in 'Animation' started by sstrong, Nov 12, 2020.

  1. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,205
    Is there a way to determine if a Trigger is set or is a condition of the current state?
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,497
    animator.GetBool might tell you if it's set since a Trigger is just a fancy Bool.

    But you can't get any info about the transition conditions in an Animator Controller at runtime.
     
  3. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,205
    Yeah, GetBool "works" with triggers but as you probably have guessed doesn't help much. I guess that's why you created your set of assets ;) My code already works with bool parameters but I'm trying to get it to work with Triggers too.
     
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,497
    A minor reason yeah, but even if you could access transition details at runtime the fact that you are forced to define important logic outside of your code is a massive design flaw.

    Even before I made Animancer I never used Triggers. I set up all my states on their own with the only transitions being exit time transitions back to Idle for non-looping actions, then I used animator.Play or CrossFade to play them. That lets you avoid wasting time setting up and debugging parameters and transitions. It's nowhere near as effective as Animancer, but at least it puts some of the logic back into your scripts where it belongs.
     
    NikitaUseDeveloper and sstrong like this.
  5. NikitaUseDeveloper

    NikitaUseDeveloper

    Joined:
    Feb 1, 2023
    Posts:
    1
    It is a good advice, thank you