Search Unity

Issue with animations inside a model

Discussion in 'Animation' started by Amitheattack, Feb 26, 2015.

  1. Amitheattack

    Amitheattack

    Joined:
    Feb 26, 2015
    Posts:
    14
    I created a house in blender complete with 7 doors. I prefer to use the animator in unity. The issue I am having is that when I import the house and drag that same house into my world I can not seem to animate the doors individually. If I create a cube in unity I can have it do what ever I want, with the doors I can not. Is it because the doors are a child to the house? Any help would be great as far as I can animate the doors to open and close.
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    That shouldn't be an issue, if you think about it a few second most animation case are always like that, you have a hierarchy of animated transform that give life to your character.

    1. First make sure that each door have a unique name. Unity bind animation curve base on the transform path + property name. If all your door share the same name, only the first door will be animated.
    2. Also when you import your file in Unity, set your importer rig type to generic, this will prepare your asset to be animated by the animator component.

    Once you are done with 1 and 2 you should try to create some animation inside Unity with the Animation window in record mode.

    Drop your asset in an empty scene, select the your house GameObject, open the Animation Window and click on the record button, any modification that you will do on your gameobject will create keyframe, so select one of your door and rotate it to create an animation curve for this door. Rince and repeat for each door.
     
  3. Amitheattack

    Amitheattack

    Joined:
    Feb 26, 2015
    Posts:
    14
    Ok so feeling kinda dumb wasn't putting the script on the actual house I was putting on the door. Which kinda leads me to my next question. If I have to store all the animations in the actual house and the script to open the door how would I call on a specific animation? For example to open the front door would I have to make sure the front door model gets hit by a ray cast by the player model then the player would have to press E then the door opens? Would this be the right way to go about coding it so every door stays closed while that one door open?
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    What I would do in this case is import the house without any rig attached.
    Create one controller that open and close a door.
    Add an Animator on each door and set your controller.
    This way each door can be openned/closed individually.

    Take a look at this tutorial it should give you a good idea how to do it
    http://unity3d.com/learn/tutorials/projects/stealth/single-doors
     
    theANMATOR2b likes this.
  5. Amitheattack

    Amitheattack

    Joined:
    Feb 26, 2015
    Posts:
    14
    Got it thank you so much. I removed the rig set it to none then I can add an animator and a animation to the door then I can put the script on the door also thank you so much.