SCP:CB style door interaction

Hello Unity Users,I have a question

Is it possible to make the door interaction in SCP:CB to unity?

I want my door to be like SCP:CB.If you are looking at the door’s button,then a GUI pops up with a hand icon or some sort.The GUI must hover over the door’s button.

Hopefully you can answer my question

You can easily create a generalized Use script with the help of Raycasting and SendMessage. Simply shoot a raycast wherever your character is looking at at all times, and use SendMessage to trigger a Use() function in whatever it is you want to use. You will have to manually program these functions yourself.

Shooting a raycast at all times instead of just when the user presses E has the advantage of allowing you to have a GUI indicator whenever you hover over something that can be interacted with (Tags are a good way to mark which objects should trigger the message, and in my example, i assume that you tagged all of the usable objects with the “Usable” tag). The overall layout should be like this:

var guiTimer:float;
var hit:RaycastHit;
function Update(){
  if(/*physics raycast code*/){
     if(hit.collider.gameObject.tag=="Usable"){
        guiTimer=Time.timeSinceLevelLoad+0.2; //Timer to determine whether to show GUI or not
        if(Input.GetKeyDown("e")){
           hit.collider.gameObject.SendMessage("Use");
        }
     }
  }
}
function OnGUI(){
  if(guiTimer>Time.timeSinceLevelLoad)
    //Draw your GUI here
}

This code would allow you to call the Use() function on the objects tagged as “Usable” when the player presses E. Since we are using SendMessage, we don’t have to specify the behaviour the use function is in. Be careful with using SendMessage frequently though, as it is somewhat expensive.

i found something Unity 5 Tutorial : Open door using a 3D button - YouTube