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
3
Question by tBurger · Oct 13, 2015 at 04:06 PM · mecanimproblem during runtimelatency

Mecanim Initial State Transition 1 Frame late

Hello everybody,

I got a little issue I'm running into regularly: I got an object with an animator attached which has an initial state where it is practically instantly made invisible. But in reality it is not turned invisible instantly but flashes up for a frame.

The only workaround so far is to have the object made manually invisible in the inspector while editing which is really tedious if I want to change something. (Because I have to make it visible again, make my edits and turn it back invisble again, when I'm done)

My biggest problem with this is, that the animator seems to need a whole frame until it finally applies the first frame of it's initial state.

Any thoughts on that. Anyoune experienced the same issue?

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 meat5000 ♦ · Oct 13, 2015 at 05:45 PM 0
Share

Can you add in a frame 0? Never tried, it may not work.

avatar image tBurger · Oct 14, 2015 at 07:20 AM 0
Share

I don't think that's even possible! I assume if the first frame already has an index it will be 0.

3 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by tBurger · Oct 14, 2015 at 09:51 AM

Okay I found a way!

Another lead to this problem was the though the animator gets updated to late. So I've added this:

 void OnEnable()
 {
     _animator.Update(Time.deltaTime);
 }

Which forces the animator to update (i.e. to do whatever is set in the first frame of it's initial state) ahead of it's usual time. Seems to work so far!

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 huulong · Nov 08, 2016 at 09:58 AM 2
Share

It works even with a null or negative deltaTime value. It seems that the Unity animator just needs any kind of Update to kick off and update the animated properties immediately. Therefore, if you want to start your animation from the beginning, you can use animator.Update(0f)

If you want to skip the 1st frame, pass the animation frame period, etc.

avatar image
0

Answer by anilo · Oct 13, 2015 at 09:58 PM

You should add the make it invisible logic to your awake function.

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 tBurger · Oct 14, 2015 at 07:21 AM 0
Share

Unfortunately if I want to set a property in script that is already controlled by an animation curve the script changes are ignored.

avatar image
0

Answer by huulong · Oct 27, 2016 at 03:10 PM

If your animator's Update Mode is set to Animate Physics, your object will refresh at a different rate than the view which may cause the flash. If you don't need physics update, set the Update Mode to Normal.

I tried on my project and it worked, but I still wanted to have physics update so instead I decided to initialize the object on Awake in a initial invisible state, and to switch to a visible state later in the game when the object is used.

If you cannot do that either, you can do like anilo said, making the target object invisible in your script, just after the object is created (so either Awake or in the method that spawn the object). If the rendered object is at the component root, you cannot just deactivate the object since it will also prevent the animator from updating, but you can deactivate the rendering components.

In your comment, you said that the animation curve would override your changes. But since your initial state is also supposed to make the object invisible (hence the flash), it should not revert what you did in the script so the object will start and remain invisible until the animation makes it visible.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Mecanim control animation frames via script? 2 Answers

Mecanim How Animate Bone a Ball Using Humanoid? 0 Answers

Is there a way to use physics to keep a character from clipping through itself during an animation? 0 Answers

Mecanim Anim screwing up character 2 Answers

Dynamically attaching a skinnedMeshRenderer to existing character 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