K
K
kidmasaomiyt2020-10-31 09:51:00
Unity
kidmasaomiyt, 2020-10-31 09:51:00

How to correctly determine if a button is pressed in a [Unity] trigger?

When I get to the trigger, then 1 displays... but when I press E nothing happens.

void OnTriggerEnter2D(Collider2D col){
    if (col.gameObject.name == "Player"){
      print ("1");
      if (Input.GetKey (KeyCode.E))
        print ("Open");
    }
  }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question