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 MrMonstr · May 03, 2013 at 07:19 PM · animationjavascriptcharactercontrollerjavascript-specific

Why doesn't this animation script work?

 function Start () {
     animation.Play();
 }
 
 function Update () {
     if (Input.GetAxis ("Horizontal") < 0) {
         animation.Play("walkL");
         }
     else if (Input.GetAxis ("Horizontal") > 0) {
         animation.Play("walkR");
         }
     if (Input.GetAxis ("Vertical") < 0) {
         animation.Play("walkB");
         }
     else if (Input.GetAxis ("Vertical") > 0) {
         animation.Play("walkF");
         }
 }

This is an animation code for my character. I think it's obvious what I'm trying to do, (Animate WASD movement) but I keep getting errors and my character doesn't animate.

The animation state walkF could not be played because it couldn't be found! Please attach an animation clip with the name 'walkF' or call this function only for existing animations. UnityEngine.Animation:Play(String) scriptRockanoidAnimate:Update() (at Assets/scriptRockanoidAnimate.js:16)

Also this error:

Default clip could not be found in attached animations list. UnityEngine.Animation:Play() scriptRockanoidAnimate:Start()

(at Assets/scriptRockanoidAnimate.js:2)
Comment
Add comment · 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 roojerry · May 03, 2013 at 07:25 PM 0
Share

Are the animations attached to the object you want to animate?

avatar image MrMonstr · May 03, 2013 at 07:58 PM 0
Share

They are in the blender file. I also put them in the Animation Component in the object.

avatar image MrMonstr · May 04, 2013 at 06:07 PM 0
Share

Found the answer. no problem now. thx anyway!

3 Replies

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

Answer by MrMonstr · May 04, 2013 at 06:21 PM

For anyone else. I have fixed the problem. Animations need to be set as Legacy. In the rig tab of the object. Change where it says Generic to Legacy. Now it works! :D

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 azmat786n · May 03, 2013 at 08:09 PM

 //then simply call the function like this
 if(Input.GetKeyDown(KeyCode.XX) {
     PlayAnimation("animation name as string");
 }
 
 
 //copy below code to your script that object attached animations
 //function about play animations
 function PlayAnimation(AnimName : String) {
     if (!animation.IsPlaying(AnimName))
     animation.CrossFadeQueued(AnimName, 0.3, QueueMode.PlayNow);
 }
 
 
 i hope this is helpful to you :D
Comment
Add comment · Show 5 · 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 MrMonstr · May 03, 2013 at 08:23 PM 0
Share

I used this code, I got the same errors

  function PlayAnimation(AnimName : String) {
      if (!animation.IsPlaying(AnimName))
      animation.CrossFadeQueued(AnimName,0.3, Queue$$anonymous$$ode.PlayNow);
      }
  function Update () {
      if (Input.GetAxis ("Horizontal") < 0) {
          PlayAnimation("walkL");
          }
      else if (Input.GetAxis ("Horizontal") > 0) {
          PlayAnimation("walkR");
          }
      if (Input.GetAxis ("Vertical") < 0) {
          PlayAnimation("walkB");
          }
      else if (Input.GetAxis ("Vertical") > 0) {
          PlayAnimation("walkF");
          }
  }

Do tell me if this is wrong.

avatar image roojerry · May 03, 2013 at 08:27 PM 0
Share

If you are still getting the same errors as above, the animations are not attached to the object correctly. I dont know how else to help you other than to tell you to double check that the animations are attach to the same object that this script is attached to, and all the names match exactly

avatar image azmat786n · May 03, 2013 at 08:29 PM 0
Share

wait i am checking your script and also finding your another problems :)

avatar image azmat786n · May 03, 2013 at 08:35 PM 0
Share

please put here which error you faced now using this script...?

avatar image azmat786n · May 03, 2013 at 08:43 PM 0
Share

delete all of above your script create new scene and put your animated object in their scene then delete previous component from object add animation component new then add one animation and in the animation component options check (Play automatically) second step also select (Always Animate) then test if your object animate in play mode then fine if not play then your object not properly exported from blender :) lets do it this is the final way to check your problem ...

avatar image
0

Answer by PS · Sep 10, 2013 at 02:16 AM

Thanks. This works :-)

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

15 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

Related Questions

Controlling Mecanim through javascript? 2 Answers

how to take maya animation file in to unity? 1 Answer

How would you implement a first-in first-out queue system in javascript? 0 Answers

Play Animation on Button Down 1 Answer

Enter Trigger, play animation(s) and sound FX 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