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 komodor · Feb 27, 2014 at 10:40 AM · mecanimupdatedelay

Mecanim 1 frame delay [solved]

all animations are facing right, when i change character direction the turn animation faces one way after turn, in the same update i flip change transform:

 transform.localScale = new Vector3(1f, 1f,0.001f);

or

 transform.localScale = new Vector3(-1f, 1f,0.001f);

i am calling flip and new animation on the same frame / update and i can see one frame glitch, where animation is not changed but character is already flipped

what can i do? is there some delay in mecanim?

**EDIT: it was all wrong since beginning, when i changed movement from adding Vector3 every frame to current position to Vector3.Lerp() between start and end the problem dissapeared completely

sorry for bothering and thanks for trying to help


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
1
Best Answer

Answer by Griffo · Feb 27, 2014 at 03:05 PM

I use

 yield WaitForSeconds(0);

As in

     _animator.SetBool( paramName, true );
     yield WaitForSeconds(0);
     _animator.SetBool( paramName, false );
Comment
Add comment · Show 5 · 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 komodor · Feb 27, 2014 at 03:10 PM 0
Share

thanks for your answer, i did not specify, that i call directly

 animator.Play(animationClip.Name, 0, 0f);

which (by my opinion) should start immediately and without fading; it's called from Update and I don't use any coroutines in the project

avatar image Griffo · Feb 27, 2014 at 03:16 PM 0
Share

have you tried looking Here

I'm off to work now so won't be online for hours .. :(

if flip and new animation are called one after the other you shouldn't be see a one frame glitch.

avatar image komodor · Feb 27, 2014 at 03:58 PM 0
Share

I understand how it should work, it just don't :D I must be doing something wrong, here's the code:

     public virtual IEnumerator PlayAnimation(StateInfo animationClip, float duration = float.NegativeInfinity)
     {
         yield return new WaitForEndOfFrame();
 
         debugAnimationClipName = animationClip.Name;
         if (duration > 0)
         {
             animator.speed = ((animationClip.Length*60f - 1f)/60f)/duration;
         }
         else
         {
             animator.speed = 1f;
         }
 
         animator.Play(animationClip.Name, 0, 0f);
 
         if (isFacingRight && transform.localScale.x < 0f)
         {
             FaceRight();
         }
         else if (!isFacingRight && transform.localScale.x > 0f)
         {
             FaceLeft();
         }
 
         // return null;
     }

if I comment the yield line and uncomment the return line, than it works as before (sometimes glitch)

avatar image whydoidoit · Mar 03, 2014 at 12:26 PM 0
Share

Are you animating physics?

avatar image komodor · Mar 03, 2014 at 05:04 PM 0
Share

no physics

avatar image
1

Answer by funshark · May 20, 2014 at 06:33 PM

I have no answer but the same problem currently. Every transition in mecanim have a 1 frame delay

frame 1 : the parameter is checked

frame 2 : the state is activated

frame 3 : the animation in the state is played

( so it's 2 frames in reality )

I'm curious how everyone is dealing with that since it has a big impact on how well the game responding to your inputs :/

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 komodor · Sep 25, 2014 at 11:08 AM 0
Share

dunno if you problem is same as $$anonymous$$e, but in my case it was wrong movement, the mecanim was ok, i had error eslewhere, when i changed movement from incremental Vector3 to Lerp all went fine

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

Mecanim, start blend immediately? 0 Answers

Resetting a combo chain 1 Answer

How to update 3D character 1 Answer

Cant get rid of animation delay in Mecanim 2 Answers

Weird delay on Tween 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