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
1
Question by adslitw · Mar 27, 2013 at 03:23 PM · animationmecanimtime

Set the current time / frame of a Mecanim animation

Using the old system this is easy to do:

 animation["Walk"].normalizedTime = 0.5F;

Gives us the middle point of the animation. Is this possible using Mecanim?

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

5 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by komodor · Jan 24, 2014 at 12:16 AM

dunno, but now you can do just:

 Animator.Play(state, layer, normalizedTime);

if you use

 Animator.Play("same state you are", -1, 0f);

it will restart current state, if you put whatever float from 0 to 1 into normalized time, you can set it to any time position you want

you can also use

 Animator.CrossFade(state, crossFadeTime, layer, normalizedTime);
Comment
Add comment · Show 3 · 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 EDarkness · Jan 24, 2014 at 05:09 AM 0
Share

Has anyone been able to solve this problem yet?

In the old animations, my code waited for the midpoint of an animation to calculate whether or not something got hit. Under mecanim, I have no idea how to do this.

In my old system, I did this:

animTime = $$anonymous$$athf.Round(Animation[myBody.attack1].normalizedTime * 10)/10; if (animTime == 0.5f) {

do something

}

Does anyone know how to do this using mecanim?

avatar image komodor · Jan 24, 2014 at 10:05 AM 0
Share
  1. maybe you should start your own question, because nobody will find this

  2. i believe you can achieve this by animation events with or without mecanim http://docs.unity3d.com/Documentation/Components/animeditor-AnimationEvents.html

avatar image JCX · Jan 24, 2014 at 10:23 AM 0
Share

Thanks komodor, I was looking for it!

avatar image
4

Answer by piacentini · May 18, 2015 at 10:35 PM

As I stumbled across this issue as well, here is my simple solution now that ForceStateNormalizedTime is deprecated (Unity 5)

 animatorcomponent.Play("yourste", -1, 0.5f);
 animatorcomponent.speed = 0;

If you do not set the speed to 0 the animation will simply play from the new initial frame until the end.

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

Answer by simsimsim · Aug 28, 2013 at 09:53 AM

In mecanim you can set the normalized where to start the animation in the transition.

To start a walk cycle with the other foot (left instead of right) you could create a boolean parameter named RightFootFirst. Then in the transition from idle to walk check if the RightFootFirst is true also. Create an other transition which is identical except thet now it RightFootFirst needs to be false and then set the offset of the walk state to 50%.

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

Answer by 10yaseen1 · May 07, 2013 at 10:59 AM

you can use the new Mecanim system in unity 4 which also supports the nomalised time function, for example

 function Update (){
 
 
    if(animator){
 
    if(basecurrentstate.IsName("Base Layer.AIM")){
 
     animator.ForceStateNormalizedTime(1.0);
 }
 }
 }

but remember it works for the Base Layer only. Hope it helped, Good Luck :)

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

Answer by tgraupmann · Dec 28, 2013 at 05:46 AM

If you have a longer animation, you can see the current playing state completely ignores the deprecated ForceStateNormalizedTime.

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

16 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

Related Questions

Animator idle minimal delay 0 Answers

Mecanim how get time of the animation 0 Answers

Make Mecanim animation play completely dependent on framerate? 0 Answers

Get time when the animation starts in Animator Controller 1 Answer

Control Animator time from script 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