Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 william9518 · Oct 09, 2013 at 12:51 AM · animationvariablemissingreferenceexceptionanimation.play

Unity thinks my animation is not attached, but it is.

I am currently trying to make a soldier play an animation for a third person view for my multiplayer game. I had just imported the BootCamp soldier in for a placeholder, along with all the animations. In my script, I had wrote:

 anim.animation.CrossFade("Standing");

And apparently the Unity Console tells me the animation 'Standing' is not attached to the anim GameObject, but it clearly is. The complete error is the following:

 The animation state Standing could not be played because it couldn't be found!
 Please attach an animation clip with the name 'Standing' or call this function only for existing animations.
 UnityEngine.Animation:CrossFade(String)
 MultiplayerMulti:UpdateAnimations() (at Assets/_Scripts/MultiplayerMulti.js:56)
 MultiplayerMulti:Update() (at Assets/_Scripts/MultiplayerMulti.js:35)

MultiplayerMulti line 56 is just the line I had provided above. alt text

As you can see, it is CLEARLY attached to my Soldier object. And yes, the soldier object IS SET AS THE GameObject for the anim variable! Any idea what the real problem is is appreciated.

Thanks in advance, william9518

screenshot.png (184.0 kB)
Comment
Add comment · Show 4
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 TonyLi · Oct 09, 2013 at 02:11 AM 0
Share

Please paste the complete console message into a comment, as well as the code that sets anim. Also, add this line and provide the output (assu$$anonymous$$g C#):

     Debug.Log("anim is " + anim.name);
avatar image william9518 · Oct 10, 2013 at 01:17 AM 0
Share

Alright, and I have already debugged the anim variable.

avatar image TonyLi · Oct 10, 2013 at 03:39 AM 0
Share

Can you play the animation on the character in the Animation View window?

Also, before the anim.animation.CrossFade("Standing"); line, try enumerating all the clips in the Animation component. You could add a couple lines like this:

 foreach (AnimationState state in anim.animation) {
     Debug.Log(string.Format("[{0}]", state.name));
 }

I added square brackets above so you can see if maybe the animation clip has a blank space at the beginning or end of the name.

avatar image william9518 · Oct 10, 2013 at 09:59 PM 0
Share

Yes I can. And I will try the debugging.

2 Replies

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

Answer by william9518 · Oct 11, 2013 at 01:27 AM

I fixed it by not doing it at all. I revamped the system with Animators.

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 tanuj0092 · Oct 10, 2013 at 04:46 AM

Probably the question description is still unclear whether you are directly using the object or instantiating the object . However, there are several possibilities in your case. First, in the image you are showing is the prefab of the soldier on which the animation is attached. Check whether the object which is placed in the scene i. e. the hierarchy, the animation is attached to it or not. If not then you probably need to redrop the object. If it doesn't work then you need to instantiate the object through code.

It is showing you the error just because the object present in the hierarchy doesn't have the animation file attached to it. Do one thing, place your object in the hierarchy from the project window, check whether Animation is attached to it, use that object as a reference through the script and instantiate that object. It would definitely work.

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 william9518 · Oct 10, 2013 at 09:58 PM 0
Share

It is being instantiated through code. Also, I am using Network.Instantiate, so I cannot instantiate anything that is not a Prefab.

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

17 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

Related Questions

How to assign "data" in script at runtime 0 Answers

i need a help in script to move while he is animation? 2 Answers

How can I increase the value of a variable? 1 Answer

Animay play in editor 0 Answers

Is it possible to change a variable, into a script not assigned to any game object? 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