• 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
Question by GelasoftDevs · Oct 09, 2014 at 07:22 PM · animationjavascript

Strange MissingComponentException while everything looks ok

I just started creating my first game using Unity and I already stucked. I tried to animate a mace and run the animation when the left mouse button is clicked, but I'm getting t$$anonymous$$s strange error:

 MissingComponentException: There is no 'Animation' attached to the "Mace" game object, but a script is trying to access it.
 You probably need to add a Animation to the game object "Mace". Or your script needs to check if the component is attached before using it.
 UnityEngine.Animation.Play (System.String animation) (at C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/Animations.cs:569)
 MeleeSystem.Update () (at Assets/MeleeSystem.js:11)

Reffering to t$$anonymous$$s script:

 #pragma strict
 
 var theDamage : int = 50;
 var Distance : float;
 var maxDistance : float = 1.5;
 var TheMace : Transform;
 
 function Update (){
 
 if(Input.GetButtonDown("Fire1")){
     TheMace.animation.Play("Attack");
         var $$anonymous$$t: RaycastHit;
 
         if(Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), $$anonymous$$t)){
             Distance = $$anonymous$$t.distance;
             if(Distance < maxDistance ){
                 $$anonymous$$t.transform.SendMessage("ApplyDamage", theDamage, SendMessageOptions.DontRequireReceiver);
             }
     }
 }
 }

Where line 11 is: TheMace.animation.Play("Attack");

I have done everyt$$anonymous$$ng as it shoud. Here is a screenshot of my workspace:

img

Where:

1) is the Melee - you can see that the Mace is a c$$anonymous$$ld of it. 2) the Melee script. 3) TheMace variable is assigned correctly.

I know that I miss a small part here, but as a complete beginner, I just can not spot it. Can you give me a push?

untitled.png (237.5 kB)
Comment

People who like this

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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Graham-Dunnett · Oct 09, 2014 at 07:24 PM

Click on the Mace game object. The inspector will show you the components that are on t$$anonymous$$s game object. You should see an Animation section, where you have specified the animations w$$anonymous$$ch can be applied to it. The error seems to be saying that the Mace game object does not have t$$anonymous$$s component.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to fix Animation 1 Answer

Why isn't my animation being played? 0 Answers

Changing number of frames in uvAnimationTileX 0 Answers

Using animationState for animation controls 2 Answers

how character's legs(tps) move? 0 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