Comparing GameObjects without using name or tag.
Hello!
Question :
How do I compare a GameObject with a collider.gameObject obtained from a raycast, to figure wether the collider is the said GameObject, but without using names or tags?
Question.end;
To summarize things a bit, I have quite a big instanced group of objects (handles that I use to drag selected items around in 3D, with a parent Empty that holds the script and detects clicks and drags), itself the child of the object it moves, and I use a raycast to detect which handle is clicked to subsequently drag it, etc.
The obvious answer for this particular case is to allow only one object to be selected at a time and tag the hell out of the handles, but the problem also presents itself when selecting the (potentially) massive amount of objects on scene.
Given the amount of (clone)objects with the same name and tag that will be on scene, I cannot test for tags or names, and I resort to instantiation/destruction of non-critical items to alleviate the game's load (it's a board game and it dosen't care about "performance" like a shooter or a RTS would)
I cannot have a script running on each object on the scene, but that forces me to identify them by raycast and not by "OnClick" or whatever that function is called.
I'd be very grateful for help on this matter. And I'd also gladly recieve any criticism pertaining to my «general idea», should anyone have a good way to improve it.
Thanks in advance!
Your answer
![](https://koobas.hobune.stream/wayback/20220612074919im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Random.range game object destroying itself before reaching destroy position.Please help. 1 Answer
Can not access GetComponentInParent ( ). usegravity 1 Answer
How to find the transform position of another gameobject then move a gameobject to that position? 1 Answer
How to make multiple game object work with the same scripts? 0 Answers
Moving grabbed object OnTriggerStay2D 0 Answers