Hello I have a script this script must destroy a object when the player is in the triggerzone and press e. but if the player is in the trigger zone and presses e all the objects disappear. instead of the only objects the player is in. Here is the script:
#pragma strict
var Enter: boolean;
var ItemID: String;
var ItemName: String;
var Stone: GameObject;
var Player: GameObject;
var Controller: GameObject;
var Items: Items;
function Start () {
Items = Controller.GetComponent("Items");
Stone = GameObject.Find("triggerStone0");
}
function Update () {
if(Enter && Input.GetKey("e")) {
Debug.Log("Just picked up item: " + ItemName + " " + "ItemID: " + ItemID);
Destroy(Stone);
}
}
function OnTriggerEnter (col : Collider) {
if(col.collider.tag == Player.tag) {
Enter = true;
}
}
function OnTriggerExit (col : Collider) {
if(col.collider.tag == Player.tag) {
Enter = false;
}
}