Collecting Items from a Table

I have a table in my scene with weapons on it, each with their own colliders and tagged as “collectible”. I want the user to be able to collect the item they are hovered over with the mouse when they press “F”. I tried some things and could only make it so it collects all the items on the table…but thats not what i want. how would i make it so only the item under the mouse is collected?

Thanks

You could post the code so that we might suggest changes, but without the code, the easiest I’d imagine would be to just use a Unity - Scripting API: Camera.ScreenPointToRay in which case you’d just have to check if the object hit by the ray is a item that can be picked up or not… the only problem with that would be that you have to make sure that the cursor is on the object…

if you’d like to have some area that can detect the object around the cursor location, you could try to use Unity - Scripting API: Physics.SphereCast

there are all kinds of ways to do it, it would really help if you’d show some of the code you have :slight_smile: