The problem is that when I press the button (in this case tab) it calls the function multiple times? Is there a way to only read the button press once? As of right now all I want this code to do is to print the name of the nearest enemy. It works for that, but prints 4 or times.
Code snipet:
function OnGUI(){
if(Input.GetButtonDown("target")){
Debug.Log(FindClosestEnemy().name);
} }