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
1
Question by Tjakal · Aug 07, 2011 at 02:12 PM · animationyieldwaitforseconds

Problem with 'animation.CrossFade' and 'fadeLength'.

Greetings! This is my very first post on the forums.

I've been developing a third person shooter over the last couple of weeks in order to learn unity so far I've found everything I've needed by browsing old posts here and reading the scripting manual but now I've been stuck with this probably simple problem for way to many hours..

I have a setup where holding the Mouse2 button moves the camera to look over the shoulder, (Resident Evil/Mass Effect style). At the moment I just use a 1 frame pose of the character aiming down the sights of a rifle. In order to blend into this pose I use, the following from inside LateUpdate (have other animations playing underneath):

 animation.CrossFade("aim",aimDelay); //for full body aiming stance.
 animation.CrossFade("aimUpperBody",aimDelay); //for aiming while walking.


Where aimDelay is of course a float value. Problem is the delay works only the first time character shoulders the weapon, after that it snaps into position instantaneously. Testing everything I could think of I noticed that when raising the 'aimDelay' from what it's supposed to be (in the order of a fraction of a sec) to something very high like half a minute - if mouse2 is released prematurely, before weapon is fully raised, pressing it again will continue to raise the weapon from the point it had previously reached, like 50% raised at 15 seconds etc. Like the aimDelay value is a pool of time that the crossFade keep chewing up til' empty.

I've tried all sort of crazy things including the obvious not so crazy stuff like rewinding the animation before doing the crossFade tested different wrapping modes, multiply by Time.deltaTime or do a 'curTime' strip of the time etc, but no joy.

I figure I can always go into max and just animate the sequence and solve it that way, but I also feel to stubborn to surrender. reading the forums I notice no one seems to have any similar issues so I can't shake that I may be missing something obv?


If I may be as rude as to sneak in a bonus question:

I feel I have a very similar problem with all my 'yield WaitForSeconds(x)'in functions that they just do the wait the first time a function is called and then pass straight past the 'yield' every time?

If anyone could tell me what's up with that I'd be a very happy man for several minutes, perhaps even a full hour.

Thanks for reading!

Comment
Add comment · Show 1
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 Joshua · Aug 07, 2011 at 02:25 PM 0
Share

Can't really help you on the CrossFade problems, but I can tell you that yield WaitForSeconds( t ) should definitely wait t seconds every time. For instance:

 function YieldExample()
 {
     while( 1 > 0 )
     {
         Debug.Log("something")
         yield WaitForSeconds( 2.5 );
     }
 }

will, after being called once, Log Something every 2.5 seconds.

0 Replies

· Add your reply
  • Sort: 

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

Loop Animation with delay-variable 1 Answer

Loop animation with a wait in between 3 Answers

Yield waitforseconds not consistent for animation-unity2D 0 Answers

Yield until animation is over? 1 Answer

WaitForSeconds vs yield every frame 3 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