- Home /
Best Way To Translate Object Name To Inventory?
I'm trying to come up with a simple, but effective, looting system.
I am using a ray to store the objects name, but how would I translate that objects name to an object value in an inventory script. The objects on the ground will all be named differently.
I know I could easily use
if(hit.transform.name == "Specific Item Name"){
myInventoryScript.Ak47 = 1;
}
And then ask if Ak47 > 0{ Ak47.SetActive(True); }
But that just seems too simple, and would become too messy in the future. I'm not an expert programmer, but I would like to access an ID from that weapon and send it to the inventory script. And then if I hold that value add that weapon to a current weapons list that I can cycle through by changing weapons with a key.
I am basically asking is there a cleaner more effective way about doing something like this.
Thanks.