• 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 /
  • Help Room /
avatar image
Question by gtav225 · Jan 18, 2017 at 08:41 PM · erroranimatornullreferenceexception

PLEASE help, the Anim.SetBool or Anim.SetFloat s are sending tons of errors!

hi, i need help with fixing this, i dont know whats going on, about 1 or 2 months i was using the same script and having animators running well, but now i turned the (UseAnimator) variable "on" in inspector, and tested it, it gave me tons of null errors! i swear i attached the animator through Update and the parameters exists in the animator, just when the parameter has to work, like sitting on ground, it gives null errors, the script line of Animator:

 private function AnimatorManager ()
 {
     if(UseAnimator)
     {
         if(UsePower)
         {
             Anim.SetFloat("Power",Power);
         }
         Anim.SetFloat("Vertical",Input.GetAxis("Vertical") && GroundChecks.Grounded && Controllable);
         Anim.SetFloat("Horizontal",Input.GetAxis("Horizontal") && GroundChecks.Grounded && Controllable);
         Anim.SetBool("Run",Input.GetButton("Run") && GroundChecks.Grounded && Controllable);
         Anim.SetBool("Jump",Input.GetButton("Jump") && GroundChecks.Grounded && Controllable);
         Anim.SetBool("Crouch",Crouch && GroundChecks.Grounded && Controllable);
         Anim.SetBool("Inside Water",InsideWater && Controllable);
         Anim.SetBool("Grounded",GroundChecks.Grounded && Controllable);
         Anim.SetBool("Near Fall Grounded",GroundChecks.NearFallGrounded && Controllable);
         Anim.SetBool("Mid Fall Grounded",GroundChecks.MidFallGrounded && Controllable);
         Anim.SetBool("Far Fall Grounded",GroundChecks.FarFallGrounded && Controllable);
     }
 }

Also the AnimatorManager function called in function update! but i dont know whats wrong with these lines of code! The Error Message:(its one error that i pasted it here, actually they're about 9 errors) NullReferenceException: Object reference not set to an instance of an object PlayerController.AnimatorManager () (at Assets/Player Controller/Scripts/PlayerController.js:165) PlayerController.Update () (at Assets/Player Controller/Scripts/PlayerController.js:75)

is there a way to fix it? i appreciate any answers!

Comment

People who like this

0 Show 3
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 doublemax · Jan 18, 2017 at 09:46 PM 0
Share

If it says "Object reference not set to an instance of an object", you can be sure that this is exactly the problem.

But as you posted only a part of the code, so we can't know which line number refers to which code line, this is all that can be said.

avatar image gtav225 doublemax · Jan 18, 2017 at 09:55 PM 0
Share

actually for example, the line says: Anim.SetFloat("Vertical",Input.GetAxis("Vertical")); when i press forward or backward, the error instantly appears, and also when i press jump button, it appears another error , when i press left or right, it appears another one, so it means each of them doesnt work for no reason :(

avatar image doublemax gtav225 · Jan 19, 2017 at 12:16 AM 0
Share
 Anim.SetFloat("Vertical",Input.GetAxis("Vertical") && GroundChecks.Grounded && Controllable);

If that line shows the above mentioned error, it can only have one of two reasons: Either "Anim" or "GroundChecks" is null. (Theoretically "Input" could be null, too. But it's highly unlikely, so we'll ignore that).

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by gtav225 · Jan 19, 2017 at 12:45 PM

The Error Occurred because of unity version maybe, yesterday i Updated Unity to 5.5 and the error gone! im enjoying playing around like GTA 5, thanks for your time and answers :D

Comment

People who like this

0 Show 0 · 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

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

108 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 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 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 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 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

Can't get (added) components from Empty Object, Animator giving me a hard time.,Can't get (added) components from Empty Object, animator get's on my nerves. 0 Answers

NullReferenceException: Object reference not set to an instance of an object Groundcheck.OnTriggerEnter2D (UnityEngine.Collider2D col) (at Assets/object/code/Groundcheck.cs:17) 0 Answers

Getting this error:BCE0020: An instance of type 'UnityEngine.Animation' is required to access non static member 'Play'. 1 Answer

NullReferenceException: Object reference not set to an instance of an object ... Why? 1 Answer

Why am I getting a null reference error? 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