- Home /
How to check if an object is in a group of the hierachy
So basiclly I need that i can check in my code if an object is in the same group for me the group "items" . so i can type in my javascript code
if( transofrm.isingroup("items") { do something. }
i tried it with the Layers it worked but then i couldnt select it in the scene anymore and only through the hierachy which pissed me off to much and i cant use tags because i dont want to have a group of items. so i use it already use tags for it and it would work BUT you can only assign one tag for an object so it is not working
here the code that you understand what i want:
(here needs to be the missing code and after that this follows)
if(Input.GetKeyDown("e")) { if(hit.collider.gameObject.tag == "pickupstone") { Destroy(hit.collider.gameObject); Inventory.inventoryArray[0] ++; } if(hit.collider.gameObject.tag == "pickupwood") { Destroy(hit.collider.gameObject); Inventory.inventoryArray[1] ++; }
thanks for help!
Your answer
