Search Unity

error CS1061: 'Animator' does not contain a definition for 'Setbool'

Discussion in '2D' started by Deleted User, Aug 28, 2019.

  1. Deleted User

    Deleted User

    Guest

    Hello I get a problem with animator but I don't understand why. this is what the console says:

    Assets\Scripts\Player.cs(155,36): error CS1061: 'Animator' does not contain a definition for 'Setbool' and no accessible extension method 'Setbool' accepting a first argument of type 'Animator' could be found (are you missing a using directive or an assembly reference?)

    if i press on the error i get to my code here:


    Code (CSharp):
    1. private void HandleMovement(float horizontal)
    2.     {
    3.         if (myRigidbody.velocity.y < 0)
    4.         {
    5.             myAnimator.SetBool("land", true); // i think this is the problem but am not sure
    6.         }
    7.         if (!myAnimator.GetBool("slide") && !this.myAnimator.GetCurrentAnimatorStateInfo(0).IsTag("Attack"))
    8.         {
    9.             myRigidbody.velocity = new Vector2(horizontal * movementSpeed, myRigidbody.velocity.y);
    10.         }
    11.         if (isGrounded && jump)
    12.         {
    13.             isGrounded = false;
    14.             myRigidbody.AddForce(new Vector2(0, jumpForce));
    15.             myAnimator.SetTrigger("jump");
    16.         }
    17.         if (slide && !this.myAnimator.GetCurrentAnimatorStateInfo(0).IsName("Slide"))
    18.         {
    19.             myAnimator.SetBool("slide", true);
    20.         }
    21.         else if (!this.myAnimator.GetCurrentAnimatorStateInfo(0).IsName("Slide"))
    22.         {
    23.             myAnimator.SetBool("slide", false);
    24.         }
    25.  
    26.         myAnimator.SetFloat("speed", Mathf.Abs(horizontal));
    27.     }

    Thanks already

    Kind Regards
     
    Last edited by a moderator: Aug 28, 2019
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    The actual error is not in the code you posted here.
    The error message tells you which line in which script is throwing the error:
    Assets\Scripts\Player.cs(155,36)

    In Player.cs, line 155, character 36.

    And judging by the description of the error:
    'Animator' does not contain a definition for 'Setbool'

    It appears you've just made a typo on this line.
    It should be "SetBool", not "Setbool".
     
    ahmdsomro, hahazz4 and Deleted User like this.
  3. Deleted User

    Deleted User

    Guest

    Hello Vryken thank you
     
  4. Anujkumar2442005

    Anujkumar2442005

    Joined:
    Jan 8, 2022
    Posts:
    4

    Hello sir I also got same problem with animator but I don't understand why. this is what the console says:

    Assets\script\player.cs(53,14): error CS1061: 'Animator' does not contain a definition for 'setBool' and no accessible extension method 'setBool' accepting a first argument of type 'Animator' could be found (are you missing a using directive or an assembly reference?) Screenshot (25).png Screenshot (26).png Screenshot (27).png
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,727
    The complete error message contains everything you need to know to fix the error yourself.

    These are just your own fatfinger typos. Capitalization must be PERFECT and your capitalization is incorrect.

    Go look in the documentation to learn how to capitalize the function it says does not exist.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

    ALSO, please don't post to old forum threads for unrelated simple typo issues.
     
  6. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    497
    So you necro a topic and then don't actually follow the instructions for how to fix a typo?
    The very first reply to the original topic post says:
    The only difference is that the OP had used
    Setbool
    , and you have used
    setBool
    .
    You could have also found the answer in the manual if you had searched for the
    setBool
    as it would have shown you that the method is actually
    SetBool
     
    Chubzdoomer and shamanik100 like this.
  7. Anujkumar2442005

    Anujkumar2442005

    Joined:
    Jan 8, 2022
    Posts:
    4
    Thank you sir
    You help me a lot . From next time I will remember it :):)
     
    bennediction and Kurt-Dekker like this.
  8. Kelvi919

    Kelvi919

    Joined:
    Apr 12, 2021
    Posts:
    2
    check if you have "private Animator animation;" or "private Animation animation;"