Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 VicciGames · Aug 13, 2011 at 03:15 PM · animationlayerscrossfade

Animations are different when in lower layers

I have 4 animations made inside unity. Shoot IDLE ADS ADS OUT

The problem is that when I have my shoot animation on a layer above all the others, it plays the whole animation with all the curves set but it overrides all the other animations when playing.
Also, if I set it below the other animations or inbetween and even not a layer at all, the animation does not play the position change, If I can get the position animation to show with the shoot animation instead of just the rotation, that would be great!
Hope it wasn't confusing!
Here's the code.

     var firerate = 2;
 var adsspeed = 1;
 
 function Update () {
 //LAYERS
 animation["IDLE MP5"].layer = 1;
 animation["MP5 SHOOT"].layer = 2;
 animation["ADS MP5"].layer = 3;
 animation["ADS OUT MP5"].layer = 3;
 
 //WRAPMODES
 animation["MP5 SHOOT"].wrapMode = WrapMode.Loop;
 animation["IDLE MP5"].wrapMode = WrapMode.Loop;
 animation["ADS MP5"].wrapMode = WrapMode.ClampForever;
 animation["ADS OUT MP5"].wrapMode = WrapMode.ClampForever;
 
 //SPEEDS
 animation["MP5 SHOOT"].speed = firerate;
 animation["IDLE MP5"].speed = 1;
 animation["ADS MP5"].speed = adsspeed;
 animation["ADS OUT MP5"].speed = 1;
 
 //BLEND MODES
 
 animation["IDLE MP5"].blendMode = AnimationBlendMode.Blend;
 animation["ADS MP5"].blendMode = AnimationBlendMode.Blend;
 animation["ADS OUT MP5"].blendMode = AnimationBlendMode.Blend;
         
         
         
         
 //SHOOTING
 if (Input.GetButton("Fire1"))
 {
 animation.CrossFade("MP5 SHOOT", 0.5);
 
 }
 else
 {
 //IDLING
 animation.Stop("MP5 SHOOT");
 animation.CrossFade("IDLE MP5", 0.5);
 }
 
 
 //ADS
 if (Input.GetButton("ADS"))
 {
 animation.CrossFade("ADS MP5", 0.05);
 }
 else
 {
 //ADS OUT
 animation.CrossFade("ADS OUT MP5", 0.2);
 
 }
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Owen-Reynolds · Aug 13, 2011 at 05:52 PM

That code is running every frame. When you press FIRE, it fades into shoot for 1 frame, but next frame the ELSE says to resume idle. To see that, change to GetButton -- holding fire should now play shoot. Instead of the else, you somehow want to say "play idle when fire is done running."

The common solution is to make shoot a "PlayOnce" (can use the Inspector,) and put it on a higher layer. Play idle in Start (or Awake) and never touch it again. Then have FIRE play shoot. Shoot will "cover up" idle, then fade out, uncovering idle (you will see it come back.)

Unity's AnimationIntroduction explains the whole layer and covering up idea.

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 VicciGames · Aug 13, 2011 at 06:03 PM 0
Share

No, that didn't work for me. The thing about the PlayOnce and layer part of the shoot animations is the aim down the sight animation. That would snap it back to the shoot animation if you hold aim and shoot down.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

walk crossfade run animation based on joystick position need help please 0 Answers

Unity 3.5 Animation : stop one layer 1 Answer

Play an animation just on some parts of the body 1 Answer

Shaking skinned mesh animations 1 Answer

Animation: Impact of combining the use of Layer, CrossFade, and Weight 2 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