- Home /
Duplicate Question
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?
use ontrigger animation, so when someone activate the the ontrigger event the animation will play, the animation should have two part one is for the upper part and the other one is for the down part.
Answer by theAfrican · Jul 01, 2013 at 10:11 AM
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");
}
}
you create an empty gameobject. give it a box collider and set it around the door, say 2m apart in and out of door. add that script to it. lemme edit answer so as you can just add the door objects
You're not going to get far in Unity, or in life for that matter, waiting for someone else to write every script you need. What you're trying to do is pretty basic and has been asked many many times here. The help theAfrican already gave you was generous, but if you had RTF$$anonymous$$ in the first place; you would have seen OnTriggerExit right after OnTriggerEnter. Stop begging, start learning.
Follow this Question
Related Questions
How to script a door opening with points...please help 1 Answer
Moving Objects along a vertices 1 Answer
Door opener 1 Answer
looking for help with item pickups 1 Answer
Script to make an enemy follow the player when they trigger a door? 0 Answers