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
1
Question by CG-DJ · Apr 15, 2013 at 09:42 PM · animationplayoncecrouchall

Not playing entire animation when it is called.

Ok, be patient with me, I'm new at this :)

I'm making my first person character crouch when the "c" button is pressed. I want to be able to press the button and the crouch animation be played and then the character comes back up to a standing position. The problem is, when I hit the C button, I get the first 3 frames of the animation, but nothing else! Yes, my animation wrap mode is set to "Once".

 function Update(){    
         // If you press Crouch
     if(Input.GetButtonDown("Crouch"))
     {
         Crouch();
     }
 }
 
 function Crouch()
 {
     arms.animation.CrossFade("MCArm_crouchAll", .1);
 }

also, in this script, I have all the Character Movement scripting. I don't know if this is how you're supposed to do it, but it is how I did it, but I made it so that whenever a key is not being pressed, the idle animation is played: function Update () {

     //If no key presses
     if(!Input.anyKey)
     {
         arms.animation.CrossFade("MCArm_idle", 0.2);
     }
 
     // If you are hitting "Forward"
     if(Input.GetAxis("Vertical") > 0)
     {
         transform.Translate(0, 0, walkForwardSpeed*Time.deltaTime);
         arms.animation["MCArm_walk"].speed = walkForwardAnimationSpeed;
         arms.animation.CrossFade("MCArm_walk", .5);
     }
        //(ETC like this)

I don't know if that is part of the problem or not, but I don't think it is....

Comment
Add comment · Show 3
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 CG-DJ · Apr 15, 2013 at 11:21 PM 0
Share

Come on guys...I'm really hitting a wall here...

avatar image Negagames · Apr 16, 2013 at 12:54 AM 0
Share

How do your other animations work? Are they having any problems? I know when I last imported models in fbx format that ALL the animations where botched. Also, try setting the crouch animation to loop, that might work.

avatar image CG-DJ · Apr 16, 2013 at 03:11 AM 0
Share

Thanks for the tip, but I fixed it. It was doing this cause I had another animation playing when no keys were pressed.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CG-DJ · Apr 16, 2013 at 01:20 AM

HA!!! Fixed it!

So anyone who has this problem, this is what I did to fix it. It may be a special case for me because of the way I did my idle animation, but I needed to put my [play idle animation] line inside of a if(!arms.animations.IsPlaying) statement. Thus, if there are no other animations playing, then I will be idle.

     //If no key presses
     if(!Input.anyKey || action == false)
     {
         if(!arms.animation.IsPlaying)
         {
             arms.animation.CrossFade("MCArm_idle", 0.2);
         }
     }
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 Snaiel · Feb 26, 2017 at 10:21 AM 0
Share

Oh my god thanks so much xD, had the same problem where the idle animation was playing...

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

13 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

Related Questions

Animation keeps looping even on WrapMode.Once; 1 Answer

Unity Animation just play once 1 Answer

Play animation with key once 1 Answer

Preventing all animations from playing? 0 Answers

Cannot get sprint animation to play when crouch works fine? 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