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?
-
Create an empty game object(doortrigger) which parents upperdoor and lowerdoor.
-
Give it an animation Component.
-
Create the animations “openlowdoor”,“opentopdoor” for doortrigger
-
attach a box collider to doortrigger and make sure you set “isTrigger” to checked.
-
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”);
}
}