- Home /
Key interaction not working
So I'm making an inventory system, and so far, it's collision based. I want to press 'E' to pick up the object, but adding a line enforcing that seems to make it fail.
Yes, I know I should probably be using rays for this, but while it's still rudimentary, I am using colliders until I know that everything else is working as intended.
this is the part of the script that is important, but if you need another part, just say so:
public void OnTriggerEnter(Collider other) { if (other.tag == "Item") { pickup = other.gameObject; AddItem(pickup); }
I've tried to add a && Input.GetKeyDown(KeyCode.E) to the if statement, but for some reason this makes it fail.
Answer by The_GoldenDragon · Aug 06, 2021 at 03:34 PM
Not sure why the code is being added to the paragraph, but I hope it's readable
Your answer
![](https://koobas.hobune.stream/wayback/20220613041309im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to implement pickups that can go in a inventory 3 Answers
Where can I find Unity Script Tutorials that teach how to make the scripts come together? 2 Answers
Pick up gameobject and go to inventory, 1 Answer
adding inventory items is half-working 0 Answers
Inventory adds an item only once. 0 Answers