Click Meh! Open door/close when clicked.

Im a scripting noob so please go easy on me…

Ive spent a decent 10 minutes looking how to do this but all the other answers are for dragging the door open, i just want it that when clicked, the door will will open and close from its hinge at about 85 degrees. Like ive shown below. Can anyone guide me through what i need to do?




Make an animation for it, it’s relatively simple. Here is some code:

var animationName : AnimationClip;
var isOpen : boolean;
var inTrigger : boolean;
var inSight : boolean;

function Update () {

    if(Input.GetMouseButtonDown(0) && inTrigger == true && inSight == true) {
       isOpen =! isOpen;

    if(isOpen == true)
       animation[].speed = 1;
    else if(isOpen == false)
       animation[].speed = -1;

 function OnMouseEnter () {

inSight = true;

function OnMouseExit () {

inSight = false;

function OnTriggerEnter (col : Collider) {

   if(col.gameObject.tag == "Player") {
       inTrigger = true;


WARNING: Un-tested code

Edit: Made it so you have to be in the trigger and have the mouse over it. STILL UN-TESTED.

I think that good choise is rotating the object, if you have a pivot on the one side of that door, you simple could use this gameObject.transform.rotate(new Vector3(0, 0, 85));