D
D
Denchik1020302021-03-01 16:46:25
C++ / C#
Denchik102030, 2021-03-01 16:46:25

Input.GetKeyDown(KeyCode.E) not working?

I'm learning to create games, but I can't make one of the mechanics. If I remove "&& Input.GetKeyDown(KeyCode.E)", then when colliding with a friend, the player's prefab is deleted, as soon as I add it, nothing happens.

private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.tag == "Friend" && Input.GetKeyDown(KeyCode.E))
        {
            Destroy(gameObject);
        }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-03-01
@Denchik102030

Inputonly needs to be calledUpdate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question