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 John-Gray · Feb 20, 2013 at 05:13 PM · animationrotationmecanimtransitionroot motion

Mecanim Root Motion Rotation - 180 degree turn.

Hi.

I am currently trying to use an animation which turns my character 180 degrees on the spot to face the opposite direction (2D scrolling game).

When I look at the animation in the preview window it looks correct and turns the whole 180 degrees. When I play the animation at runtime however, it does not rotate enough (36 degrees short when it stops).

I have removed any blends from the animation transitions (thought some of the rotation could be getting blended away).

Below are two screenshots of the setup I have:

From Idle to Turn transition:

alt text

From Turn to Idle transition:

alt text

Any advice on how I could rectify this problem would be most welcome.

Thanks,

John.

Comment
Add comment · Show 5
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 EHogger · Feb 21, 2013 at 12:10 AM 0
Share

I solved this problem using mecanims target matching, but it was a pain to get working right. I'd be interested to see if there is a better way

avatar image meat5000 ♦ · Jul 18, 2013 at 10:45 AM 0
Share

On the transition away from turning, set EXIT TI$$anonymous$$E to be the length of the clip or change the condition to not include time factor. The exit time is what (I think) seems to be causing your early animation end.

Also, Atomic means that the animation can not be over-ridden, I think. It won't help it play in full, you shouldn't need this unless you really dont want anything to interrupt the anim.

Sorry Im months late :P

avatar image John-Gray meat5000 ♦ · Jul 18, 2013 at 10:53 AM 0
Share

This was confirmed as a bug by Unity Support and QA.

When the animation was played as a loop, the turn animation completed and turned 180 degrees.

When a transition was added, even when it was set to as close to 0% as we could get it, the animation then started to stutter based on the frame rate (low frame rate caused the animation to lose up to 50% of the total root motion).

When we submitted this as a bug to Unity, they told us the transitions are currently pretty buggy (and we have several other cases when the transitions are causing issues as well). Hopefully it will be fixed at some point soon!

The answer about target matching is correct for a humanoid rig type (which is how we fixed our humanoids) however generic rigs have no target match so it can still happen to them (but only when the frame rate is really low).

Having the Atomic checkbox checked doesn't help it play in full, however the animation should not be interrupted, so having it set to Atomic is desirable for us!

Thanks for the reply!

avatar image meat5000 ♦ meat5000 ♦ · Jul 25, 2013 at 09:59 AM 1
Share

No probs! Thanks for letting me know about the bug

avatar image ahsoka · Aug 05, 2014 at 09:00 AM 0
Share

I am developing a side scrolling game and I want my character to turn exactly 180 degrees. I resolved the problem with matchTarget with targetNormalizedTime = 0.95f even if ExitTime = 1 from turn, but when I have a blend between states, matchTarget doesn't work not matter the start/targetNormalizedTime. And I also don;t use matching in transition. Did you resolved this problem (because your post is one year old)? Thanks.

2 Replies

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

Answer by EHogger · Feb 21, 2013 at 09:50 AM

Here is the way I fixed this using target matching.

rotationTarget is set to just point forward by default, and then I switch it 180 degrees each turn.

     private Quaternion rotationTarget = new Quaternion(0,0,0,-7);
 
     static int idleState = Animator.StringToHash("Base Layer.Idle");
     static int turnState = Animator.StringToHash("Base Layer.Turn");
 
     void FixedUpdate ()
     {
         if (currentBaseState.nameHash == turnState){
             anim.SetBool ("Turn", false);
             anim.MatchTarget(anim.rootPosition, rotationTarget, AvatarTarget.Root, new MatchTargetWeightMask(Vector3.zero, 1F), 0.2f, 1f);
             
         }
     }
 
     void Update ()
     {
         if (Input.GetKeyDown(KeyCode.N)){
                         
             if (currentBaseState.nameHash == idleState){
                 
                 rotationTarget *= Quaternion.Euler(0,180,0);
                 Debug.Log(rotationTarget);
                 anim.SetBool("Turn", true);
                 
             }            
         }
     }
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 John-Gray · Feb 21, 2013 at 09:53 AM 0
Share

Thanks for the replies. I really appreciate it. I tried target matching but I couldn't get it to work at all. I will try again with the setup you used and see if I have any joy.

Thanks again!

avatar image
1

Answer by Xtro · May 23, 2013 at 06:24 PM

Hi. Lowering the Fixed Timestamp in Time Settings will fix this problem. I don't know why, but I just made few tests on it and noticed that it was the reason.

I'm using 0.015 as timestamp instead of 0.02 and my turn animation is in perfect length.

Btw, if you want to alter the Time Scale for such slow motion effects, you should alter the fixed timestamp according to it.

For example if you slow the time as 0.1 instead of 1 sec, you should also set the fixed time stamp to 0.0015 to keep your animations working good.

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 John-Gray · May 23, 2013 at 06:33 PM 0
Share

I am not sure that will help. I have tested it here and it did nothing, which is what I expected as the Timestep only affects physics calculations and how often the FixedUpdate() monobehaviour is called, which as far as I understand, have nothing to do with the $$anonymous$$ecanim animator.

avatar image Xtro · May 23, 2013 at 07:00 PM 0
Share

Timestep is also being used for the interpolations between animation keyframes.

$$anonymous$$y 180 degree turn animation was playing shorter than the original. It was rotating something like 150 degrees ins$$anonymous$$d of 180. Preview was playing the original 180 degree.

First, I did a step mode test. I clicked the pause button before I click the start button. Then I clicked the step button until the end of the animation. And BOO$$anonymous$$! it was turning 180 degree. When I play the game without step mode, it was still shorter than original. So I understood that it was about animation ti$$anonymous$$g.

I noticed that the problem is not about the transition length at all, because I placed only the turn animation into animation controller as a default and looping animation. There was no transition, no Idle and no other animations. When I play the game, it was still playing it shorter.

Then, I went to time settings. I reduced the Timestamp from 0.02 to 0.015 and that fixed my problem. I tried some other values but 0.015 is the best.

Now my 180 degree turn animation is really rotating the character as 180 degree.

avatar image PlayingKarrde · Apr 20, 2019 at 10:15 PM 0
Share

This worked for me although I set $$anonymous$$e down to 0.001. Will this have any negative impact on anything else I'm not aware of? $$anonymous$$y quick tests didn't seem to have any issues. (I realise this is 6 year old post but mainly for co$$anonymous$$g across this through google like I did).

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

Unity 5.2: Mecanim Transition Blending 1 Answer

Root motion lost in transitions 1 Answer

How to fix this Mechanim root motion problem? 0 Answers

Mecanim animation transition 0 Answers

Adding animation transition between idle and walk 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