• 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 /
  • Help Room /
avatar image
0
Question by norcrel · Oct 25, 2015 at 04:57 PM · animationanimatoranimator controller

AnimatorStateInfo.normalizedTime always returns 0

I'm trying to disable a gameObject with an animator attached, then re-enable it in the same position at the same point of animation. Right now, it re-enables and automatically plays starting from the beginning of the animation. Here's the chunk of code I'm using to record the normalized time:

     // Disable target
     m_targetAnimations = m_target.GetComponentsInChildren<Animator>();
     m_targetAnimationTimes = new List<float>();
     for (int i=0, j=m_targetAnimations.Length; i < j; i++)
     {
         Animator anim = m_targetAnimations[i];
         AnimatorStateInfo asi = anim.GetNextAnimatorStateInfo(0);
         m_targetAnimationTimes.Add(asi.normalizedTime);
         Debug.Log(asi.normalizedTime);
     }
     m_target.SetActive(false);


The Debug.Log I placed inside that loop always returns 0, no matter what point of the animation the target is in. If I hard-code and add ".5f" to m_targetAnimationTimes, the animation resumes at the half-way point every time, so I know recording the normalizedTime is where the problem lies.

Help would be greatly appreciated, I can't seem to find any way around this or any questions that are asking the same problem. Any ideas? Thanks!

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 gnp89 · Feb 24, 2017 at 07:19 PM

Are those children active? Seems like normalizedTime is 0 when gameobject is not active. Maybe those children under "target" where disabled before you execute this?

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why is the last frame of the animation not triggering? 0 Answers

animator controller doesnt work on instantiated object 0 Answers

Specific Animation not Playing 0 Answers

Help with animator controllers 0 Answers

I can't see my mesh in android app, but I do in win version 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges