how to make a solid door open and close?

i want to make a door open and close when it is clicked on while your fps controller is within a certain distance. also how do you get the animation for the door and make it play when clicked on? thnx in advance :slight_smile:

p.s. im new at this and i don’t know any scripting so i have absolutely no idea on how to go about learning that aswell. sigh

Hi, I can found the tut on youtube where i take this, but is good explained

anyway ask if have some problem,

please mark as answered if all work for you

  /*
     Instruction:
    create a cube to use as hinge put where is needed, the withe cube
    press f to meet it position
    create a cube to use as door end re-size, the brown cube
    centre the hinge at the door__________________________pic door1
    parent the hinge at the door
    
    in the inspector, centre the collider at the door re size as your need 
    and enable trigger___________________________________pic door2  
    
    Assign this script at the hinge 
     
    Press "f" to open and  close the door
    if whant change in, if(Input.GetKeyDown("f")at line 46
    Make sure the main character is tagged "player"
    when all work can remove Mash render and Mash Filter 
    */ 




    // Smothly open a door
    var smooth = 2.0;
    var DoorOpenAngle = 90.0;
    var DoorCloseAngle = 0.0;
    var open : boolean;
    var enter : boolean; 
    //Main function
     function Update ( ){
       
     if(open == true){ 
       var target = Quaternion.Euler (0, DoorOpenAngle, 0);
         // Dampen towards the target rotation
          transform.localRotation = Quaternion.Slerp(transform.localRotation, target,
          Time.deltaTime * smooth);
     }
    
     if(open == false){
       var target1 = Quaternion.Euler (0, DoorCloseAngle, 0);
         // Dampen towards the target rotation
          transform.localRotation = Quaternion.Slerp(transform.localRotation, target1,
       Time.deltaTime * smooth);
     }
    
      if(enter == true){
        if(Input.GetKeyDown("f")){
     open = !open;
        }
     }
      
    }
    
    //Activate the Main function when player is near the door
    function OnTriggerEnter (other : Collider){
    
     if (other.gameObject.tag == "Player") {
     (enter) = true;
     }
    }
    
    //Deactivate the Main function when player is go away from door
    function OnTriggerExit (other : Collider){
    
     if (other.gameObject.tag == "Player") {
     (enter) = false;
     }
    }

Door 1

2371-door1.png

Door 2

2372-door2.png

There’s a pack called ‘Easy Doors’ in the asset store should save you a lot of time for a measly 10 bucks

Hi,

I’ve created this video tutorial which will answer your question.

http://www.youtube.com/watch?v=scm7r0uBepU&noredirect=1

Hope it helps.