- Home /
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.
THANK YOU!!!
----EDIT----
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.
Answer by runevision · Apr 27, 2010 at 08:36 AM
You can use AnimationState.AddMixingTransform to specify for each animation which bones it should affect.
Example:
// 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.
Answer by e-bonneville · Apr 26, 2010 at 11:27 PM
A simple, easy solution would be to put your window animation on a separate range, like 51 - 65.
Unfortunately i can not do that, the House was just an example, the complex object hierarchy im dealing with has thousands of animation clips, all tiered in specific ways and playing at random times so i need more control, with out changing the animation keyframes :(
Your answer
![](https://koobas.hobune.stream/wayback/20220612192753im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do you move Animations inside the Animator Controller hierarchy? 1 Answer
Game object delete itself from hierarchy when I play animation 1 Answer
Begginers question, Simplifing a script, opening two doors with 2 overlapping triggers. 1 Answer
Switch holding hand when reload weapon 1 Answer
Can the animation editor create local rotational data? 3 Answers