How to make different animations affect different parts of the object?

OK! Here goes my best explanation i can think of to get this answered correctly.

Let me describe a sample object for you. I have a House object with 1 door and 1 window object parented to it. The animation range to open the door and window are both 1-25 for open and 26-50 for the close. Now, both the door and window are children of the House object. I export the house with the Door and window attached, and parented to it. Bringing it into Unity gives me a hierarchy of a House with two children, door and window. I have 4 animations to declare on import Door open (1-25), Door close (26-50), Window open (1-25), Window close (26-50). The house object contains these animations since its the top of the Hierarchy correct? Now when i click on the door to play Door open (1-25), it plays.. But so does Window open (1-25) since its part of the main House object.

How can i fix this??? Any insight would be so helpful. I'm newish to dealing with animation in unity.



Well i just tried Storing Animation in Original Roots in the import section, hoping that would work. What i did was re-import with those settings, then i had to go into the hierarchy of the object and manually adjust the animation size and add the animation clips to the objects i wanted to animate. Clicking on them now results in an error stating that the Animation can not be found! I have it linked up properly i think? its the same way i link it to the main hierarchy object when trying Store in main root, only this time i reference the object i want to animate specifically, since its stored in original roots.. i assume this means that the window object will hold the window animation?? Apparently not, it cant find the animation in the object, and relinking up the top of the hierarchy plays it still. Weird.

You can use AnimationState.AddMixingTransform to specify for each animation which bones it should affect.


// Adds a mixing transform to the "Open window" animation
// so it only affects bones starting from windowTransform and down.
var windowTransform : Transform;
animation["Window open"].AddMixingTransform(windowTransform);

This solution assumes you are not using Store Animation in Original Roots in the import settings.

A simple, easy solution would be to put your window animation on a separate range, like 51 - 65.