if ( hit.collider.name == ("Exemple[0]") not working. is there a way to hit an array GameObjec?
hi guys, it's all in the title! i need to know wich trees i hit with my raycast when i click them, my trees spawn randomly, so i need to create an array [ ] list, exemple if i have [20] array slot, i'll be able to generate 20 trees randomly, to cut them and make them spawn again! but if i click one of them to open the UI to cut the tree, they all open the UI, so my raycast hit need to know wich trees it hit, and with an array [ ] list, it's supposed to be Ok, but (hit.collider.name == "exemple[0] ") or (hit.collider == "exemple[0]") None work.
Any idea? Thanks for help.
Your answer
Follow this Question
Related Questions
Check if position is inside a collider 5 Answers
Raycast hit 2 Answers
Highlighting with a Raycast 1 Answer
RaycastHit.normal and Vector3.reflect problem 0 Answers
how do I call a function from another script, when Raycast Hits? 1 Answer