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 thevraptor · Jun 07, 2014 at 05:59 PM · animationjavascriptbooleaninput.getaxisanimation.play

Animations Not Working

Howdy,

There has been a problem in my game for about two weeks now and it has been driving me insane. I have a BasicAnimations javascript I wrote that is supposed to play a walking animation when walking, and two jumping animations, one after another, when jumping. The problem is that when I'm doing a running jump, none of the animations play when the jumping animations are supposed to play. When I'm not doing a running jump and just jumping up and down, the jumping animations play regularly. Like I've said, I've been studying this script for two weeks, and I still don't know how to solve it. I know it has something to do with the jumping animations and walking animation playing at the same time, but I'm not sure how to fix it. I've tried everything, and I am tearing my hair out. Thanks.

 #pragma strict
 
 var grounded : boolean;
 grounded = true;
 
 function Update () {
 
     if (Input.GetAxis("Horizontal") && grounded == true) {
         animation.Play("walk");
     }
         
     if (Input.GetAxis("Vertical") && grounded == true) {
         animation.Play("walk");
     }
         
     if (Input.GetButtonDown("Jump") && grounded == true) {
         grounded = false;
         animation.Play("jump start", PlayMode.StopAll);
         animation.PlayQueued("jump end", QueueMode.CompleteOthers);                                          
     }
     
     if (grounded == false) {
         animation.Stop("walk");
         grounded = true;
     }
 }
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
0
Best Answer

Answer by thevraptor · Jun 14, 2014 at 07:40 PM

I have now fixed this problem using coroutines. Thanks for your help though!

 #pragma strict
 
 var grounded : boolean;
 var random : boolean;
 grounded = true;
 random = false;
 
 function Update () {
 
     if (Input.GetAxis("Horizontal") && grounded == true) {
         animation.Play("walk");
     }
         
     if (Input.GetAxis("Vertical") && grounded == true) {
         animation.Play("walk");
     }
         
     if (Input.GetButtonDown("Jump") ) {
         animation.Play("jump start", PlayMode.StopAll);
         grounded = false;
         animation.Stop("walk");
         animation.PlayQueued("jump end", QueueMode.CompleteOthers);
         Grounded ();
     }
 }
 
 function Grounded () {
     
     yield WaitForSeconds(1);
     grounded = true;
 }
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 MetalTux99 · Jun 07, 2014 at 07:39 PM

I think problem is a overlap of animation: if (grounded == false) { animation.Stop("walk"); grounded = true; I had the same problem and I found an only solution, an orrible solution: delete "animation.Stop("walk")" and try to change the name of the animation so that Unity can't find the animation "walk" and it plays only the other one. Console will shows errors but ignore it. I'm sorry for my bad English.

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 thevraptor · Jun 10, 2014 at 12:04 AM 0
Share

yes but then i wont be able to play the walking animation when walking

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

22 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

Related Questions

Play either the first or second animation on an object without specifying its name 1 Answer

animation not working 0 Answers

Animation Script 1 Answer

How to set an Animator Boolean with JavaScript 1 Answer

How would I go about carrying out another object's animation IN C#! 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