• 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
Question by coffiarts · Feb 19, 2013 at 03:41 PM · animationblendermecanimbonesadditive

How to combine mecanim and script based bone movement/animations?

Hi guys,

I am strugling with a challenge for with I can't find a reasonable approach, even after reading tons of posts. It has to do with animating my blender created player model with mecanim and script based bone movement and all of this in a network game using RPC.

I have the impression that there are various approaches to solve this, though none of them seems to match my situation. So I'd be very glad about some hints from the experts!

I've created my character model in blender 2.65 and rigged/animated it in blender. I've imported it successfully into my game and added a mecanim based animator for controlling and animating the basic movements (fwd, back, strafe left/right etc.). As a result, each of them is playing/blending nicely the correct animations from the blender model. This works great both as a single player and in network/multiplayer mode via RPC.

So far so good.

But now I am stuck in trying to add/mix additional bone movements (like looking up/down or crouching etc., by modifying the spine bone's rotation). These movements should be controlled by player input (mouse axes) instead of by the animation itself, and smoothly blend into them.

I've learned so far from the forums that this is a commonly known challenge, because the blender animations usually claim full control over the bones, thus blocking any additional mouse induced movement/rotation. But this can usually be solved by using LateUpdate() instead of Update() for applying the additional (player controlled) bone transform modifications.

So am using LateUpdate() now, and it works fine - but only as long as I am in single player mode.

In network mode however, where I am broadcasting the spine bone rotation changes over RPC, the other players' models are always nastily "flapping" and "snapping" like crazy between the standard (animation based) and additional (player controlled) positions/rotations.

I am sure that this is (logically!) because the "competing" changes induced both by the animation and by the LateUpdate() function are always somewhat laggy via RPC. In single player mode, this lag is probably just too small for being noticeable, whereas in network mode, it's too big to be neglected.

That's why I need another solution for it. In other words: I need to find a way of really blending my different bone modifications, instead of just overriding one with the other in the LateUpdate() every frame.

So, after some more research, I found that such a thing might be solved by using the animation.AddMixingTransform function (e.g. here: http://answers.unity3d.com/questions/126368/how-to-rotate-a-bone-during-an-animation.html). But this does't seem to be possible for me, because that function requires an animation component. And as I have animated my character with mecanim, I don't have animation components, only an animator component.

So I am quite confused about which way to go, e.g.:

  • Is there any way to use AddMixingTransform event with my mecanim animator?

  • Should I rather give up mecanim and use animation components instead?

  • Is there any other solution for my basic problem that I've just missed?

Thanks for any help! Hoping I am not the only one cracking his head over this... :)

Comment
Fattie
$$anonymous$$
eelstork
Mencapento
Shiasu-sama

People who like this

5 Show 1
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 coffiarts · Feb 19, 2013 at 05:12 PM 0
Share

Sorry, the link given in the above post was wrong. Just corrected it. The post related to the AddMixingTransform solution is this one: http://answers.unity3d.com/questions/126368/how-to-rotate-a-bone-during-an-animation.html

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by coffiarts · Feb 21, 2013 at 10:42 PM

Just wanted to let everyone know that I've sorted out this issue, thanks to other people's help. Please see this thread for details and follow the comments by Owen Reynolds: http://answers.unity3d.com/questions/126368/how-to-rotate-a-bone-during-an-animation.html

Solution summarized:

The problem turned out to be a simple and logical one, related to (natural) lag over RPC: You need to store the most recently known rotation value and ensure that any remote clone of the player model applies this recent value at least once per frame (to be done easily within the LateUpdate() function). This ensures that the animation cannot make the bone snap back whenever an RPC call should be missing or late.

Comment
Fattie
$$anonymous$$
Emile-Swain
eelstork
Mencapento

People who like this

5 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 Fattie · Feb 21, 2013 at 10:43 PM 0
Share

Impressive ....

avatar image

Answer by Alexandros1313 · Feb 27, 2013 at 04:41 PM

hi, I think that the simpler way to implement additive animations is to add a new animation layer in your mecanim state machine. In the (Late)Update function you can countinue to check the behavior to have in different states of each animation layer. It's fully explained in mecanim tutorial on youtube.

Comment

People who like this

0 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 coffiarts · Feb 27, 2013 at 09:30 PM 0
Share

Thanks for replying. In fact, I've gone through the tutorial beforehand, and my initial thought was actually to use animation layers, as described by you. But then I couldn't see how to control my model's bone movement by mouse input within an animation. I don't want to play a fixed animation, but the spine bone to react to mouse movement.

Did I miss something there?

Well, of course, I was already thinking about creating a simple "bow down/up" animation and then use Animation functions to play that animation up to a certain frame, in order to get specific bone positions. But I expected this to become quite complex and was unsure whether this would be a recommended solution. But maybe that's what you're referring to?

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Weird issue with Blender animation running riot in Unity 2 Answers

How to animate model with some mesh missing? 2 Answers

Mecanim : is it possible to use the same Generic animations on multiple objects sharing the same skeleton ? 0 Answers

Blender Animations to Unity Mecanim 2 Answers

Mecanim root bone loses animation on y axis 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