i want that after the closet goes forward the script ends so that when you press e again the drawer won’t move, ho can i do this, the sctip s this one:
using UnityEngine;
using System.Collections;
public class Drawer : MonoBehaviour {
public bool inTrigger = false;
public GameObject Closet;
void OnTriggerEnter (Collider Other){
if(Other.tag == "Player"){
inTrigger = true;
}
}
void OnTriggerExit(Collider Other){
if(Other.tag == "Player"){
inTrigger = false;
}
}
void OnGUI (){
if(inTrigger == true){
GUI.Box(new Rect (500,300,150,25),"Press E to open");
}
}
void Update (){
if(inTrigger == true){
DrawerMovement();
}
}
void DrawerMovement(){
if(Input.GetKeyDown(KeyCode.E)){
transform.position = Closet.transform.position - Vector3.left* 1f;
}
}
}