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

my unity engine doest have SetTrigger

Discussion in 'Getting Started' started by benjaroman_84, Apr 26, 2021.

  1. benjaroman_84

    benjaroman_84

    Joined:
    Apr 26, 2021
    Posts:
    10
    Hey everybody, i want ask your help for a little problem i have, i was setting up an animation and my Unity Enginge doesnt recognized SetTrigger, can any1 help me out here plz??

    upload_2021-4-25_23-52-9.png


    upload_2021-4-25_23-53-48.png

    Thanks in advance

    Regards!
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,842
    The problem is in your declaration of "animator". It's not shown above, but we can tell from the error message that it is an Animation, not an Animator.
     
  3. benjaroman_84

    benjaroman_84

    Joined:
    Apr 26, 2021
    Posts:
    10

    thanks!!! i ll try that
     
  4. benjaroman_84

    benjaroman_84

    Joined:
    Apr 26, 2021
    Posts:
    10
    Hey, i tried but didnt work, animator is a function i created,

    upload_2021-4-28_0-43-28.png

    i tried Animation.Settrigger and got an error anyway :(

    upload_2021-4-28_0-43-7.png

    Cant understand why i doesnt work, plz help!
     
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,134
    To be blunt you're trying to use a language without understanding how to use the language.

    No. It's an instance of a class.

    There are two problems here. One, like @JoeStrout mentioned it's the wrong class. Two, you're trying to call the method of the class directly when you should be calling it through the instance.

    You need to change this:
    Code (csharp):
    1. private Animation animator;
    To this:
    Code (csharp):
    1. private Animator animator;
    Then you need to change this:
    Code (csharp):
    1. Animation.SetTrigger
    To this:
    Code (csharp):
    1. animator.SetTrigger
     
  6. benjaroman_84

    benjaroman_84

    Joined:
    Apr 26, 2021
    Posts:
    10
    cool thank u very much
     
  7. benjaroman_84

    benjaroman_84

    Joined:
    Apr 26, 2021
    Posts:
    10

    it work thank you very much