• 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
1
Question by mastersam92 · Jul 12, 2014 at 03:51 PM · java

Please help! animation problems...

hey guys i made a animation and it worked and all but when i pressed play to test it it kept saying the animation state could not be played because it could not be found... i dont get it what should i do? heres the coding i used.

 #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("Mace attack");
         var hit : RaycastHit;
         if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
         {
             Distance = hit.distance;
             if (Distance < MaxDistance)
             {
                 hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
             }
         }
     }
 }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by JusticeAShearing · Jul 12, 2014 at 04:19 PM

I can't see any obvious errors, so all I can do is show you tutorials that helped me and my Java-Script with animations in. A notation tells you where the animation is.

 var speed : float = 6.0;
 var twiceSpeed : float = 10.0;
 var jumpSpeed : float = 8.0;
 var gravity : float = 20.0;
 var rotateSpeed : float = 3.0;
 
 private var moveDirection : Vector3 = Vector3.zero;
 
 function Update() {
     var controller : CharacterController = GetComponent(CharacterController);
     if (controller.isGrounded) {
         //Grounded, so recalculate
         //Move directly from axes
         moveDirection = Vector3(0, 0, Input.GetAxis("Vertical"));
         
         //Rotation Code
         transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0);
         
         moveDirection = transform.TransformDirection(moveDirection);
         moveDirection *= speed;
         
         if (Input.GetButton ("Jump")) {
             moveDirection.y = jumpSpeed;
         }
         
         //Animation Code
         if (Input.GetKeyDown("w"))
         {
             animation.Play("Full Walk");
         }
         else if (Input.GetKeyUp("w"))
         {
             animation.Stop();
             animation.Play("Idle");
         }
     }
     
     //Apply Gravity
     moveDirection.y -= gravity * Time.deltaTime;
     
     //Move Controller
     controller.Move(moveDirection * Time.deltaTime);
 }


Bones: https://www.youtube.com/watch?v=KLmNgeNK9ng&list=PLB4DA4F8BDC3B82EE&index=16

Animation: https://www.youtube.com/watch?v=SJS-6S_Vwdg&list=PLB4DA4F8BDC3B82EE&index=17

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 mastersam92 · Jul 12, 2014 at 04:30 PM 0
Share

where do i put it... and im a newb btw so i really dont get what your showing me.. :(

avatar image mastersam92 · Jul 12, 2014 at 04:34 PM 0
Share

btw it continueously plays but still says it not found

avatar image JusticeAShearing · Jul 13, 2014 at 04:09 PM 0
Share

Firstly, it is a movement script with animations attached. It is applied to your character and the animations are in an attachment called "Animations". I think that this is mandatory for successful operation, but maybe not. It certainly looks for the animations, though.

It isn't found probably for reasons above. However, the code states that it only plays on condition of W-$$anonymous$$ey down, so that indicates that only the can't-find-it error needs to be solved.

avatar image
1

Answer by eshonbel · Jul 12, 2014 at 04:41 PM

You need to make sure you have the Animation component attached to TheMace. Also, you need to add the animations in your Project tab into the component. Make sure the animations are named correctly!

Comment
Add comment · Show 2 · 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 mastersam92 · Jul 12, 2014 at 04:45 PM 0
Share

its not letting me drag the "melee" (my animation name) to the mace's animation thing

avatar image mastersam92 · Jul 12, 2014 at 04:48 PM 0
Share

IT WOR$$anonymous$$S THAN$$anonymous$$S GUYS!!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Please help, OnMouseDown function not working. 1 Answer

GameObjects being instantiated on top of each other 1 Answer

Zombie attack script animation help! 0 Answers

Smoothing Directionally between three materials 1 Answer

cannot create key in keystore 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