• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by wmichaelv · Mar 02, 2014 at 09:50 PM · error

UnityEngine.Animator doesn't contain a definition for 'setInteger'

I have some coding background already (C, C++, js, Ruby), but I'm still relatively new to unity library and C#. According to the documentation: http://docs.unity3d.com/Documentation/ScriptReference/Animator.html UnityEngine.Animator should have the setInteger and setBool functions to be defined, but unfortunately, my script runs errors when debugging using them. Here is my code:

 using UnityEngine;
 using System.Collections;
 
 public class AliceStand : MonoBehaviour {
 
     private Animator animator;
     
     // Use this for initialization
     void Start() { animator = this.GetComponent<Animator>(); }
     
     // Update is called once per frame
     void Update() {
 
         /*
          *  Basic Movement Keys:
          *  
          *  direction 0 = idle, no need to has 5
          *  shift for dashing
          *  mouse for reverse movement
          *  action for negate movement
          *  animator.SetInteger("direction", 0 - 9)
          *  animator.SetBool("shift", true - false)
          *  animator.setBool("mouse", true - false)
          *  animator.setBool("action", true - false)
          * 
          */
 
         var horizontal = Input.GetAxis("Horizontal");
         var vertical = Input.GetAxis("Vertical");
 
          Vector2 v2Pos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
         Vector2 objectPos = animator.transform.position;
   
         v2Pos = v2Pos - objectPos;
 
         int direction = getDirection(horizontal, vertical);
         bool mouse = getMouse(v2Pos.x, v2Pos.y, direction);
 
         animator.setInteger("direction", direction);
         animator.setBool("shift",(Input.GetKeyDown(KeyCode.RightShift) || 
             Input.GetKeyDown(KeyCode.LeftShift)));
         animator.setBool("mouse", mouse);
         animator.setBool("action", false);
     }

And these are the errors that was being thrown at me: 1. 'UnityEngine.Animator' does not contain a definition for 'setInteger' and no extension method 'setInteger' accepting a first argument of type 'UnityEngine.Animator' could be found (are you missing a using directive or an assembly reference? 2.,3.,4. Same as above, but mentioning about the 'setBool'. The rest of the code runs fine without any warning or error.

p.s. the tagging threw me off a bit there.

Regards, Michael

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Flint Silver · Mar 02, 2014 at 10:14 PM 0
Share

I don't use a lot the animators components, but according the reference if you use SetInteger( there will be only a int without a keyword ), and using GetInteger (there will be only the keyword of the int ).

and in your script there aren't the uppercase on "set" of setBool and other word...

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Eric5h5 · Mar 02, 2014 at 10:02 PM

Indeed Animator does not contain any functions that start with lowercase letters, and the documentation is correct. All functions and classes are uppercase.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image wmichaelv · Mar 02, 2014 at 10:19 PM 0
Share

Thanks! Didn't see that uppercase. Haha. Function call has been lowercase in most cases, but thanks for pointing that out!

Edit: I tested it now with all Uppercase, and the script works as intended. $$anonymous$$any thanks for the help!

avatar image Eric5h5 · Mar 02, 2014 at 10:23 PM 0
Share

All function calls are uppercase, none of them are lowercase. If you're using lowercase for your own functions, change them to uppercase. Everything in Unity and $$anonymous$$ono/.NET uses this convention, so it's a good idea to not mix things up. Lowercase is for variable names.

avatar image wmichaelv · Mar 02, 2014 at 10:29 PM 0
Share

Thank you, and will do. I'm being converted haha.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Zombie Round Script Help 1 Answer

error CS1525: Unexpected symbol `function' 1 Answer

How can i use temp variables?. 1 Answer

UnityPlayer.dll caused an Access Violation (0xc0000005) in module UnityPlayer.dll at 0033:5c78155e. 0 Answers

Android Building problem 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges