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 Octopuns · May 19, 2012 at 01:09 PM · animationcharacterblendinganimation-blending

Animation Blending Issue

I'm having an issue with getting animation blending to work (or not work).

I have a character model with an idle animation and a walk animation. The model was created and animated in Maya. The animations work fine in Unity and play as expected.

However, I am having a serious issue transitioning from the [idle] to the [walk] animation. I require [idle] to loop constantly until movement starts and then to transition from [idle] to [walk] and loop the [walk] animation once movement is detected. The problem I am having is that when the [walk] animation starts, the positions of the character's arms remain where they were during the [idle] animation when it stopped (the feet and head animate as expected).

I have tried using CrossFade, Play, CrossFadeQueued, Changing blend weights, Stopping previous animations before starting the next, resetting animation positions, etc, but can't seem to find a way to even just "reset" the arm positions before starting the walk (let alone transition smoothly between them). It appears that the animations are blending (with the walk only affecting the legs and head of the model) when I do not wish them to.

The important part of my code is below:

 function Start()
 {
    /* I have tried WrapMode.Loop too */
    animation["idle"].wrapMode = WrapMode.Once; 
    animation["walk"].wrapMode = WrapMode.Once;
 }
 
 
 function Update()
 {
     if(targetSpeed != 0)
        animation.Play("walk");
     else
        animation.Play("idle");
 }


Any help would be appreciated and I apologise if this is a frequent/silly question.

EDIT: Error appears to be a specific animation issue and not a unity issue.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Owen-Reynolds · May 19, 2012 at 03:39 PM

Are you sure that Walk plays the arms? Try just animation.Play("walk") in Start, nothing else. You're describing exactly what would happen if walk were missing the arm bones.

For some imports, in the big animation list through the Inspector, I get duplicate animations. All but one plays various subsets of bones, and I have to trial&error the correct one. I've had it where Default was walk, but animation[2] in the list was the "other", wrong walk.

Also, Loop is correct (but since you're constantly running Play, your current code turns playOnce into Loop.)

Comment
Add comment · Show 5 · 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 Octopuns · May 20, 2012 at 02:42 AM 0
Share

Thanks for answering.

Using animation.Play("walk") in Start() animates correctly and the arms DO animate. I should have mentioned that transitioning from a [walk] -> [jump] works perfectly. However, [idle] -> [walk] and [idle] -> [jump] cause the problems I've been having. So, it seems to be a problem with the idle animation.

I've checked the inspector animation list and there are no duplicates and they all appear to be assigned correctly.

avatar image Owen-Reynolds · May 20, 2012 at 03:03 AM 0
Share

I've never heard of an animation "breaking" bones that way. If you substitute some random animation for idle (shoot?) is it still broken? (I'd guess it would be, and that exact idle isn't the problem.)

Is there anything else messing around with layers or mixing transforms?

avatar image Octopuns · May 20, 2012 at 03:23 AM 0
Share

I created a short simple animation of one arm rising and then lowering (I'm not an animator) called [shoot]. When transitioning from [shoot] to [walk] (or vice versa), it blends (with crossfade) or snaps (with play) perfectly (including the arms). However, transitioning from [idle] to [shoot] also exhibits the exact same problem with the arms. $$anonymous$$oving from [shoot] to [idle] works perfectly so the error seems to occur with [idle] -> [anything].

It's probably important to note that even with the error the arms do animate "correctly", in that they translate/rotate exactly as much as they should. However, the error is in the fact that they start off at the wrong location after interrupting/blending [idle].

I have checked and there is no animation related code except for animation.Play("idle") and animation.Play("shoot").

I will quickly import the model into a completely new, empty project with a single script for animating but I don't believe that will fix the problem.

Also, while not ideal, is it possible to snap the [idle] animation to its final frame before playing the next animation?

EDIT: I've just noticed that the idle animation appears to use a joint/bone that no other animation uses. I'm not the animator (but can sort of use $$anonymous$$aya) so am unsure if this will cause problems or how to fix it.

EDIT 2: Looking at it in $$anonymous$$aya I can't even tell how/where this extra joint is (or if it's perhaps some kind of vertex transform/warping ins$$anonymous$$d). I'm almost certain that this mysterious joint is what's causing the problem, and is thus not really a unity problem at all. :|

avatar image syclamoth · May 20, 2012 at 03:35 AM 0
Share

Don't worry about it, it took me a few months to properly house train my animator too :P

avatar image Octopuns · May 20, 2012 at 03:42 AM 0
Share

I think I'll just find a new one. :P

Thanks heaps for your help, Owen (and sorry for probably wasting your time :P). I'll talk to my animator this week and then report back with what exactly it was that he did in case anyone ends up having a similar issue.

Temporary Fix/Hack (snapping to a specific frame before playing next animation):

animation["idle"].normalizedTime = 0.95; yield WaitForEndOfFrame; model$$anonymous$$esh.animation.Play("walk");

avatar image
0

Answer by Owen-Reynolds · May 20, 2012 at 04:19 PM

Yes -- an extra bone in idle would make it appear to break other animations. From Unity's point of view, every other animation is the problem, for not including that bone.

What happens is: idle rotates all bones, including mystery shoulder bone. For Walk, Unity thinks missing a bone is a specific instruction to leave that bone where it was. So, as idle crossfades into walk, mystery shoulder bone has no target in walk, so plays as in idle. When idle stops, mystery shoulder bone no has no target anywhere, so stays in that odd rotation.

I wouldn't be too hard on the animator. Most of them have only done things completely inside Max or Maya, where the rules are different. My kids sometimes export a model which looks really wrong, and I try to explain that it's in "rest pos", with no animations, and they've baked some scaling/rotations into the animation by mistake. The thing is, Max never wants to show you "rest pos," so they don't even know what I'm talking about.

Saying "every animation must include every bone" will probably solve a lot of problems (and you can "remove" bones from animations later, in Unity.)

You can move a bone yourself -- it's just a Transform (untested):

 Transform B = transform.Find("body/spine/shoulder/idleShoulderhackBone");
 Quaternion BstartRot = B.rotation;

 if(gettingOutOfIdle) {
   B.rotation = Quaternion.RotateTowards(B, BstartRot, 3);
   if(B.rotation == BstartRot) gettingOutOfIdle=false;
 }
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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Blended Animation offsetting 0 Answers

Having trouble having a player run and shoot at the same time.... 0 Answers

Softbody animations 1 Answer

Rotating arm with Animation Event 1 Answer

how to switch 2d characters animation? 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