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 Darkman2345 · Aug 25, 2013 at 06:31 PM · animationerrorplayer

Animation error please help me!

Hi im making android FPS and when i made the PlayerAnimation.cs This error arrived: "Assets/Scripts/PlayerAnimation­.cs(20,30): error CS1955: The member `UnityEngine.GameObject.animat­ion' cannot be used as method or delegate"

PLEASE HELP ME

This is my PlayerAnimation.cs: using UnityEngine; using System.Collections;

 public class PlayerAnimations : MonoBehaviour 
 {
     public GameObject Legs;
     
     private Joystick _LeftJoy;
 
     // Use this for initialization
     public void Start () 
     {
         Legs = GameObject.FindGameObjectWithTag("Legs");
         _LeftJoy = GameObject.FindGameObjectWithTag("LeftJoy").GetComponent<Joystick>();
     }
     
     // Update is called once per frame
     public void Update () 
     {
         if(_LeftJoy.position.x > 0 || _LeftJoy.position.x < 0 || _LeftJoy.position.y > 0 || _LeftJoy.position.y < 0)
         {
             Legs.animation("WalkForward").speed = _LeftJoy.position.y;
             Legs.animation.CrossFade("WalkForward");
         }
         else
         {
             Legs.animation.CrossFade("StandIdle1");
         }
     }
 }
 
Comment
Add comment · Show 6
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 fafase · Aug 25, 2013 at 06:33 PM 0
Share

I do not see any error on the specified line. Sometimes Unity goes tricky. Copy the script, delete it, recreate it and paste the script and see if it goes.

avatar image Darkman2345 · Aug 25, 2013 at 06:44 PM 0
Share

ok 1 $$anonymous$$ i try

avatar image Darkman2345 · Aug 25, 2013 at 06:47 PM 0
Share

same error :(

avatar image meat5000 ♦ · Aug 25, 2013 at 07:02 PM 0
Share

In C# doesn't the class need to equal the filename? Don't know if its related.

public class PlayerAnimations

PlayerAnimation­.cs(20,30)

Here's what a delegate is

$$anonymous$$y only stab at this is that it doesn't like the 'Legs.' in the crossfade call. (You may need to set up your animation specifics in Start() before you make the call. It's Legacy right?)

Basically you are trying to call CrossFade as a component of the Object Legs. I think this is what makes it a delegate and CrossFade connot be used this way.

EDIT : I've speculated a lot, can someone please tell me I'm wrong and why? :D

avatar image Darkman2345 · Aug 25, 2013 at 07:11 PM 0
Share

nothing work, always error but the code good i think

Show more comments

1 Reply

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

Answer by Peter G · Aug 25, 2013 at 07:33 PM

Your problem is that you are trying to index wrong. You use square brackets to index, not ()'s.

Hence this:

 Legs.animation("WalkForward").speed = _LeftJoy.position.y;

should be this:

 Legs.animation["WalkForward"].speed = _LeftJoy.position.y;
Comment
Add comment · Show 4 · 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 Darkman2345 · Aug 25, 2013 at 07:38 PM 0
Share

OOHHH Thanks, your the best THXXXXX

YEPEE

avatar image meat5000 ♦ · Aug 25, 2013 at 07:40 PM 0
Share

Good one Peter. Any chance you can explain why this throws up as being a delegate? And why the error is on the crossfade line and not the one you've quoted? Would clear up a load of stuff.

avatar image Peter G · Aug 25, 2013 at 07:55 PM 1
Share

As far as why it called the wrong line, I'm not totally sure what process it went through, but I knew it was obviously going to be within a line or two of the error. Hence I looked above it.

As to explaining why it thinks its a delegate. I can do that a little bit. The compiler sees that and it gets confused. It sees the parentheses and thinks it's a method call. And it could be. Without looking at the API, there is no way that you would know that's incorrect. Simply looking at it, it looks like animation is a function that inputs a string and outputs an object with a field named speed.

The compiler thinks something similar to this:

 class GameObject {
 
      public Func<in string , out $$anonymous$$yClass> animation;
     //Now the animation delegate takes a string and returns a class called $$anonymous$$yClass
 
 }
 
 class $$anonymous$$yClass {
      public float speed;
 }
 
 Legs.animation("WalkForward").speed = _LeftJoy.position.y;
 //Now this will compile just fine. It'd be stupid, but it would work.

That's why the compiler thinks you are trying to use it as a delegate, and obviously, animation isn't a delegate hence it's throwing the error.

avatar image meat5000 ♦ · Aug 25, 2013 at 08:36 PM 0
Share

Thanks man, much appreciated. Any chance you could also look through my comment above your answer? I'd love you forever :)

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

Multiple Cars not working 1 Answer

Marked as "Legacy" ? 3 Answers

The AnimationClip 'Running' used by the AnimationComponent 'corpse' must be marked as Legacy? 1 Answer

How To Get Current Animation Name 3 Answers

issues with animation :( 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