I am working on a game and if i want to press on a keyboard(DHD of stargate) then it must get another texture that its pressed i got this now hopefully you can help me
var texture1 : Texture2D;
var texture2 : Texture2D;
private var pressed : boolean;
private var close : boolean;
function Update(){
if (pressed){
GetComponent.<Renderer>().material.mainTexture = texture1;
}
else{
GetComponent.<Renderer>().material.mainTexture = texture2;
}
if(Input.GetKeyDown("e") && enter){
pressed = !pressed;
}
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
close = true;
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
close = false;
}
}