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 KimikoChujo · Jun 26, 2014 at 06:12 PM · animationjumpanimator controller

About AnimatorController

I'll say first. I dont speak English well because Im Japanese.

Something is wrong my script. Some animation is not playing.
Please help me.


 function Start() 
 {
     animator = GetComponentInChildren( Animator );
     controller = GetComponent(CharacterController);
 }
 
 function Update() 
 {
   //jump normal
         if( Input.GetButtonDown("Jump") ) {
         Debug.Log("jump normal");
             direction.y += jumpPower;
             animator.SetBool("Jump" , true);
             } else {
             animator.SetBool("Jump" , false);
             }
             
         //jump + direction
          if( Input.GetButtonDown("Jump") && Input.GetKeyDown("right") ) {
          Debug.Log("jump + direction");
             direction.y += jumpPower;
             direction.x +=1;
             audio.PlayOneShot(footstepsound);
             audio.volume = 0.3;
             animator.SetBool("Jump" , true);
             } else {
             animator.SetBool("Jump" , false);
             }
   
            
           //diveR
         if( Input.GetButtonDown("diveR") ) 
          {
          Debug.Log("diveR");
           direction.z +=2;
           animator.SetBool("Dive" , true);
           } else {
           animator.SetBool("Dive" , false);
           }
           
           //diveL
         if( Input.GetButtonDown("diveL"))
          {
          Debug.Log("diveL");
           direction.z -=2;
           animator.SetBool("Dive" , true);
           } else {
           animator.SetBool("Dive" , false);
           }
 }



This script is so long, I have omitted several places.

RunningAnimation and WarikingAnimation are play correctly.

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 karljj1 · Jun 26, 2014 at 08:07 PM 0
Share

What about it? Have you read the docs? http://docs.unity3d.com/$$anonymous$$anual/$$anonymous$$ecanimAnimationSystem.html

avatar image KimikoChujo · Jun 27, 2014 at 04:34 AM 0
Share

Debug.Logs work correctly. Also I have read the docs thatabout$$anonymous$$ecanimAnimationSystem. But $$anonymous$$y Animation is not play.

alt text

myanimatorcontroller.png (41.7 kB)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CandlewaxJames · Jun 27, 2014 at 04:47 AM

Just at first glance of your code, I noticed that you are using the 'Input.GetButtonDown()' method. This method only returns true for the first frame in which a button is pressed. In your code, on the next frame the animation variables are set to false. This means they are only set to true for one frame and so the animation does not get a chance to play.

I assume the walking and running animations work ok as you are probably checking the horizontal and vertical axis which will remain constantly true whilst they do not equal zero. As opposed to the GetButtonDown() method which is true only for the frame in which the button is pressed.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

C# Help with setting up jump animation 0 Answers

How to play an Animation only once from my MachineState Animator? 2 Answers

Animator Controller 2D RPG Best Practices 0 Answers

Animtion looping if joystick is held 0 Answers

How to stop an animation on collision 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