Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 drodrii · Dec 18, 2014 at 10:04 PM · c#animation2dgameobjectanimate

Animation Not Playing - VideoExplanation

Hello everyone, Im trying to play an animation by pressing a button. Heres a video of I made the animation.

So, basically you see how it's not playing even though Its running the command and how I made the animation. What am I missing? Yes, I've checked if the animation is legacy....

Thank you for your time.

////EDIT I don't like to put a whole lot of code but If you want to review it, I greatly appreciate it! This is the script attached to the gui, it enables the button for the DPad.

 public class DirectionPad : MonoBehaviour {
 
 
     bool _downPressed;
     Animation playerTempANim;
 
     GUISkin mySkin;
     // Use this for initialization
     void Start () {
 
         mySkin = GetComponent<newGUI>().mySkin;
         _downPressed = false;
 
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 
     void FixedUpdate(){
 
         if(_downPressed)
             PlayAnimation();
     }
 
     void OnGUI(){
         GUI.skin = mySkin;
         if(GUI.RepeatButton(new Rect(Screen.width - (75 * 2) - 10, Screen.height - 75, 65, 65),"", "Dpad_ArrowD")){
         //    Debug.Log ("Pressing");
             _downPressed = true;
 
         }else {
         //    Debug.Log ("not Pressing");
             _downPressed = false;
         }
     }
 
 
     void PlayAnimation(){
 
 
         if(playerTempANim == null)
             playerTempANim = GameObject.Find("testAnimation").GetComponent<Animation>();
             
 
 
         playerTempANim.Play("WalkDown");
         Debug.Log ("Playing " + playerTempANim.animation);
 
     }
 }


Comment
Add comment · Show 2
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 SkaredCreations · Dec 19, 2014 at 06:10 PM 0
Share

Since you missed to post all the code parts where you're calling PlayTempAnimation() then make sure that you're not stopping it elsewhere.

avatar image drodrii · Dec 29, 2014 at 02:00 PM 0
Share

@SkaredCreations

I posted the code.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by wesleywh · Dec 19, 2014 at 07:48 PM

So go to the animation and change the WrapMode to Loop. Otherwise it might be playing the animation once. This looks like a walk animation so you definitely want to loop that.

Also I noticed that you are doing this in your "Update()" function. That could also be another problem. A better thing to do is check for a button press on "FixedUpdate()".

Also make sure playerTempAnim in your code knows what Animation component to look at. I didn't see anything telling what playerTempAnim was.

EDIT: I also notice you never tell it to run this animation on a button press of any kind, just in the update. Make sure to tell it to run this on you press some button. Otherwise it could cause jitter or keep looping the first second of the animation.

Comment
Add comment · Show 6 · 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 drodrii · Dec 20, 2014 at 09:56 PM 0
Share

@wesleywh Thank you very much for your time and help! So, I changed Update() to Fixed Update. Nothing. Switched wrap mode from default to Loop.Nothing. I know its not best practice but I made a if statement...if 'anim' is null, find it, else play walk animation, just to make sure its doing it I made a debug just when the animation plays, its "Playing" and you can see that in the debugger when I press the button...so......I really don't know what Im missing here.

avatar image wesleywh · Dec 22, 2014 at 11:38 PM 0
Share

Could you include your code for me to review? Its very difficult for me to figure out what might be going on here without your commented code here.

avatar image drodrii · Dec 23, 2014 at 05:07 PM 0
Share

@wesleywh

What part of the code exactly? I tried to show in the video how I created a gameObject with animation component from scratch. Either way, I'll add parts of the code as an edit of the question. Thank you for your time Wesley.

avatar image wesleywh · Dec 30, 2014 at 11:01 PM 0
Share

After watching the video again I notice that u create e animation with one sprite then try to apply it to another one by the look of it. Is this what you are doing or am I missing something here? Your code looks okay to me and the debug log indicates that its working. However, in the debug log, of the video, it says playing but not what it's playing like your code says. So the two things to check are that you are making the animation for a specific sprite, and not using that animation on something else, and that your are na$$anonymous$$g your animation the same in your code as well as the inspector.

avatar image wesleywh · Jan 11, 2015 at 10:10 PM 0
Share

So in your new updated comment you say that you checked to make sure that you weren't running legacy animation.

"Animation" component = Legacy

"Animator" component = is not legacy

In your video you use the "Animation" component which is legacy. So is that different now? Btw you did look at my previous comment? Did that help you at all?

Show more comments
avatar image
0

Answer by drodrii · Dec 28, 2014 at 08:16 PM

@wesleywh

Sorry to bump this haha merry christmas ^^

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

29 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 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

Jump & Animation Script 2D 0 Answers

Animation not at correct position W/Video 0 Answers

Reverse object position order 1 Answer

Animator - Stoping && Playing from Specific frames. 5 Answers

Play an animation through script 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