Hey all, I’m pretty new to Unity and am in the middle of trying to figure this out. I have a chest that I want to open by pressing the “E” key, but I only want this to work when I am right up against the chest. So, in theory, I have a chest with a trigger in front of it so that when I walk into that area, the trigger is activated and an attached script is activated. Then, I want it to be that once I hit the “E” key, the chest will open and the trigger will destroy itself. This is what I have so far, but I’m missing the piece with the “E” key…
function OnTriggerEnter (col : Collider) { if(col.gameObject.tag == "Player") { treasureChest.GetComponent.<Animation>().Play(); Destroy(gameObject); %|919537274_4|% }
Any ideas?