Hello everyone, I have a type of weel made by one or more cells that can rotate simultaneously around an object. Each cell has a collider on it and i have created a script placed on the parent object of these cells with OnMouseDrag() event that rotateS the structure. Now, how unity references say, cell's colliders are now handled like a single collider and there is no problem with this. But what i would like to know is wich cell is being hitted or how i can change my structure in order to obtain this result? Tanks in advance!
you can give a spesific name to each of them and then you can recognize them with their name. if you want to see wich is clicked you should trace a ray from mouse position to see what will be collided. also you can use the GetInstanceID() to get the unique id of the collider and compare it to a pre built list of collider ids.
I have a similar situation where I want to know exactly where on a collider i am hitting and I use the coordinates on the texture that was hit to help determine exactly where on the object it was hit.
Ray MyRay = MyCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit MyHit = new RaycastHit();
if (Physics.Raycast(MyRay, out MyHit, 120f))
string name = MyHit.collider.gameObject.name;
Vector2 pixelUV = hit.textureCoord;
pixelUV.x *= WidthOfTexture;
pixelUV.y *= HeightOfTexture;
Does that help?