I have a situation where when the player collides with a tree it has the option to select “E” and wood will be added to the inventory.
This is my script:
void OnTriggerEnter (Collider other)
{
if (other.tag == "Tree")
{
Debug.Log ("hit");
if(Input.GetKey(KeyCode.E))
{
AddItem (2);
Debug.Log ("wood added");
}
}
}
The first debug, “hit” responds but the second does not. The AddItem (2) command works because I inserted before (Input.GetKey(KeyCode.E)). What am I doing wrong? Is Input.GetKey(KeyCode.E) incorrect?
Thanks in advanced