Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Tracey P · Oct 02, 2011 at 05:50 AM · animationscriptingbasicsanimationclip

Animation Help Needed (Method Not Found)

I am trying to add a walking animation to my charachter but when I try it says "MissingMethodException: Method not found: 'UnityEngine.Animation.play" I dont know what to do. here is my script

 var character: CharacterController;
 var speed: float = 5.0;   // moving speed
 var direction: float = 1; // direction (-1 means -x)
 var directionback: float = -1;
 var runanimation: AnimationClip;
 var placeanimation: AnimationClip;
 var attackanimation: AnimationClip;
 var dieanimation: AnimationClip;
 
 function Start(){    
         character = transform.GetComponent(CharacterController);     
 }
 
 function Update(){
     if(Input.GetKey("d")){
         character.Move(Vector3.forward * speed * direction * Time.deltaTime);
         animation.play(animation.clip.runanimation);
         }
     if(Input.GetKey("a")){
         character.Move(Vector3.forward * speed * directionback * Time.deltaTime);
         }
     if(Input.GetKey("w")){
         character.Move(Vector3.right * speed * directionback * Time.deltaTime);
         }
     if(Input.GetKey("s")){
         character.Move(Vector3.right * speed * direction * Time.deltaTime);
         }
 }

can someone plz help me. I have no idea what to do.

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
Best Answer

Answer by syclamoth · Oct 02, 2011 at 06:08 AM

You need to spell 'play' with a Capital P!

Also, animation.clip.whatever isn't the correct way of getting the animations- you should use whateverYouCalledYourAnimationClip.name; - this returns a string which can be plugged into animation.Play.

Like so-

 animation.Play(runanimation.name);
 animation.Play(attackanimation.name);
Comment
Add comment · Show 13 · 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 Tracey P · Oct 02, 2011 at 06:23 AM 0
Share

I put it it in and it says now the animation state could not be played because it could not be found?

avatar image syclamoth · Oct 02, 2011 at 06:25 AM 0
Share

$$anonymous$$ake sure that your Animation component has all of the named AnimationStates attached to it. Look at the 'Animations' dropdown inside the Animation component.

avatar image Tracey P · Oct 02, 2011 at 06:28 AM 0
Share

all of them are named the code now says animation.Play(runanimation.runn) (runn) is the name of the animation

avatar image Tracey P · Oct 02, 2011 at 06:29 AM 0
Share

and it still dosnt work it says it cant find it?

avatar image syclamoth · Oct 02, 2011 at 06:32 AM 0
Share

oooohhhh, no that's not what I meant.

I meant, runanimation.name, as in just that- the name doesn't get replace with anything, since it automatically turns into whatever the name of the animation is!

Show more comments
avatar image
0

Answer by Grady · Oct 02, 2011 at 06:06 AM

Your problem here is that you made a mistake that can be easy to make.

To play your animations, you wrote animation.play(). What you should have written was animation.Play() with a captial P!!!!

Just swap every animation.play() with the capital P. Here is the script reference for animation.Play(): http://unity3d.com/support/documentation/ScriptReference/Animation.Play.html

Hopefully this will fix your issue!!!! :D

If not, then comment back and I will try and help you more!

-Grady

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 syclamoth · Oct 02, 2011 at 06:08 AM 0
Share

There's another problem in there as well, but that's in my answer!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Playing an Animation that is within a GameObject 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Trying to check what anim clip is currently running on object 1 Answer

Empty animation clips when copying to Prefab 1 Answer

How can I reassign animation curves to play on a child object (instead of through parent)? 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