How do i make a 2 part door that opens and closes vertically?

How do I make a 2 part door (as in 1 half on top and the other on bottom (different objects inside a gameobject) and make it so that when another object ( a button of some kind) is pushed the top door piece goes up and the other down?

  1. Create an empty game object(doortrigger) which parents upperdoor and lowerdoor.

  2. Give it an animation Component.

  3. Create the animations “openlowdoor”,“opentopdoor” for doortrigger

  4. attach a box collider to doortrigger and make sure you set “isTrigger” to checked.

  5. attach the script below to doortrigger gameobject

    function OnTriggerEnter(c:Collider)
    {
    if (c.tag==‘Player’)//give your player any tag if you want the animation to start when ur player is close
    {
    animation.Play(“opentopdoor”);
    animation[“openlowdoor”].layer=1;
    animation.Play(“openlowdoor”);
    }
    }