• 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 Riderfan · Dec 12, 2015 at 11:53 PM · animationanimatortimenormalized

normalized time always greater than 1 on non-looped animations.

I'm trying to use the AnimatorStateInfo.normalizedTime property to allow me to execute code when the time reaches a specific percentage of the animation time.

I'd much rather use specfic keyframes but there doesn't seem to be a way to get what frame the animation is currently on..

The issue is that I have a non-looped animation, that is only playing once, and as soon as the animation starts, the normalized time is already over 1. According to documentation, it should only ever be between zero and never exceed 1 for non-looped animations.

So far everything is (more or less) working as expected, but the SendBallInMotion() function is called as soon as the animation starts, rather than at the end of the animation (because the normalizedtime is way over what it should be).

Is there a better way to do this sort of thing?

thanks David

Below is a screen grab of the breakpoint at the entry to a switch. You can see, that the first time this code executes, the normalizedTime is already at 1.73 and the animation hasn't even started yet.

alt text

normalizedtime.jpg (71.0 kB)
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
2

Answer by seahorsevn · Feb 22, 2017 at 08:34 AM

You can use similar code like this o fix the problem

  AnimatorStateInfo info =  m_Animator.GetCurrentAnimatorStateInfo(0);
  if (info.normalizedTime > 1 && info.shortNameHash == YOUR_ CURRENT_ANIM_HASH_NAME)
 {
     //do something...............
 }

The normalizedTime is updated late so it still keep the old value from the previous animation. So it require some frame to update new state.

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

46 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 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 avatar image avatar image

Related Questions

Animator & movements 1 Answer

Jump to specyfic time/frame in current animation using animator? 2 Answers

How do I stop animation from going past end time 1 Answer

How to end an animator animation using time? 0 Answers

Animation.NormalizedTime is not working 1 Answer

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