Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 DrVonTrap 1 · Apr 08, 2011 at 05:41 PM · animationnullreferenceexception

NullReferenceException on animation clips

so i added a load of animation clips to one of my objects, and my script has no problem with all but one of them. even clips that are referenced in the script but are not added to the object cause no problem, but the "Swipe A" clip causes a "NullReferenceException" error.

i always though that "NullReferenceException" meant that the thing i was referencing in my script couldn't be found, but i've checked and they are named exactly the same, in the same object. there is no reason i can find for this error.

is there some facet of "NullReferenceException" that i'm not understanding, or is this an know bug? any help gratefully received. thanks in advance.

Comment
Add comment
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

3 Replies

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

Answer by CJCurrie · Apr 08, 2011 at 06:02 PM

NullReferenceException means the object referenced doesn't exist. It's not exclusive to scripting. If you deleted the actual animation file from your object you'll have to reload the object.

You'll also have to specify and link each animation file to the in-scene object, in the Animations[] array in the inspector.

Comment
Add comment · Show 1 · 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 Benproductions1 · Jul 04, 2013 at 06:57 AM 0
Share

Also, with Unity 4's addition of a new animation system. Animations that are marked as the wrong type will be nullified.
However, Unity does warn about this (But that usually gets lost in all the NullReferenceExceptions) ;)

avatar image
0

Answer by IgorAherne · Apr 17, 2018 at 11:25 PM

As @Benproductions1 mentioned, it's related to an animation clip

I am using Animation, not an Animator component, and had a similar issue.

Referencing an animation from script through the [ ] operator told me the clip didn't exist - null reference exception. Surely it did! it was assigned into the array of an Animation component, it must have worked.

Turns out the animation clip was created incorrectly, and was causing troubles. The way I created it was by duplicating some other Animation clip, trying to save myself some time.

So, to fix this I selected all the properties (shift left click to select several) in the Animation window, Ctrl+C, then deleted this buggy animation clip. Afterwards, right clicked in the same folder, create -> Animation clip.

Opened it in the Animation window, ctrl+V to paste the copied properties and it worked fine - my Animation component was able to see the new clip

Comment
Add comment · 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
0

Answer by PaulRdy · Aug 06, 2021 at 08:07 PM

Hey people. Just stumbled over this because I had the issue myself (wanted to set animation time by code).

If you want to do this in a newer Unity version you're going to have to set the animation clip as "Legacy". I'd presume this is what happened when @benproductions1 created his animation clip in the alternate way.

You can do this by switching the editor to Debug-Mode and then simply setting the flag. alt text


unbenannt.png (32.5 kB)
Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Getting this character controll script working right 1 Answer

What is wrong with my script? 1 Answer

UCE0001: ';' expected. Insert a semicolon at the end 1 Answer

Weapon customize system 1 Answer

Using multiple buttons in script 3 Answers


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