This seems pretty obscure, I can't find any relevant info through searching. I made a quick (lousy) animation to test using a 'prop' bone (optional part of 3DS Max's biped rig). It changes parents throughout the anim, starting out attached to the body, then switches to the hand, then it animates itself (spins), then attaches back to the body. Simple. Works.
Brought it into Unity, attached a gun model to the prop bone, and lo and behold- it seems to work fine! It even re-parents properly like it did in 3DS Max. Great! However, this is using the Legacy animation rig, and I tend to try to avoid anything with 'Legacy' in the name for obvious reasons.
So, I decided to use a Humanoid rig instead, and it works... except as you can see, the gun seems to shift and is offset during the animation (along what appears to be the global Z-axis). It is positioned properly in the bind pose, it only becomes offset once Play is pressed and he starts animating.
I've been banging my head against this for a few hours and can't seem to find a reason why the gun's prop bone would be offset like that, especially when it clearly works (as seen in the animated Legacy version).
Any help would be appreciated. Thanks!
Answer by theANMATOR2b
Mar 15 at 01:32 PM
Can you confirm there are no scale key frames on the hierarchy, prop bone, gun mesh or hand bones? That looks suspiciously like a scaled animation key frame.
If no - I can not say for sure what the problem is, however I think I might have a suggestion.
Does the prop bone have any keyframes on it besides the IK blend keys? If there are any keyframes besides the IK blend keys - this might be causing the issue. Since the prop is an inanimate object, there should not be any keys on the prop bone anyway.
If you need animation keys to control the gun twirl, consider this approach instead.
In Max -
Align the gun to the prop bone if it is not already (make sure the pivot point on the gun is correct).
Create a dummy or point helper.
Align the helper to the guns pivot point.
Parent the helper to the prop bone.
Parent the gun mesh to the helper.
Now If you need animation keyframes - instead of animating the prop bone itself or the gun mesh, animate the helper object. The prop bone will still have IK blend keys on it, but no transformation, rotation, or scale key frames.
Thanks so much for the response!
I've double checked and I am not scaling anything in the rig at any point.
I also tried removing the gun twirl animation from the gun, so the only keyframes on the prop are to switch its parent from hip to hand. I then followed your steps and it still does not work (I think because the prop bone is still offset somehow). Is a pivot point being altered/ adjusted in Unity somehow?
As a test, I went in and made a new dummy bone not linked to anything. I went frame by frame animating the dummy to have the correct animation for the gun. Brought it into Unity, attached the gun model to the new dummy and it still does not work (still offset).
I will state again though- this is all with Humanoid rig. All of this stuff works PERFECTLY fine when I use the Legacy anim system, so I believe the issue lies in Unity and not my asset export pipeline. My inclination is that something with the Humanoid rig system is not playing well with adding additional bones, I just cannot track down where the error is occurring or why.
If there is a best practice for this type of thing, I'd love to know where to read up on it! I'm having trouble finding much info on this specific issue.
I believe you are correct. You may want to look into avatar masking. This may be the solution to your issue.
Is there a legitimate reason to try the humanoid rig? Are you planning to use existing motions or mirror functions?
Consider searching the forum for similar issues, props using the humanoid rig.
Thanks, I will check it out!
I guess the main reason for using Humanoid/ Mecanim is... its the only option besides Legacy? Also, I didn't think it would be this challenging to get props working =P
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
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.
Answers and Comments
5 People are following this question.
Can I make animations snap to a frame?
How to select an animation clip by index number?
Can the animation editor create local rotational data?
Adding animation clips via script
Getting Animations to time correctly