I have 27 sub-cubes arranged into a larger cube. I have a box collider for each sub-cube so I can get the OnMouseDown() call in a script for each to change the cube color. But I also have a script to spin the larger cube and added a box collider for it as well, which surrounds all the other colliders of course.
So now it seems I can spin the large cube, but no longer can access the OnMouseDown() functions in the sub-cubes. I tried using a RayCastAll to "penetrate" the large outer box collider to "select" a subcube, but don't get any hits.
What's the right method to do this? It must be possible... THX.
asked Dec 29 '10 at 06:21 AM
I was experiencing the same problem, if you have a RigidBody attached to the parent then you may be experiencing this:
Taken from Eric5h5's comment in: http://answers.unity3d.com/questions/32078/onmouseexit-fires-every-frame-when-the-mouse-is-down
Hope this helps.
answered Dec 29 '10 at 08:21 AM
You should definitely get some hits with RaycastAll.
Keep in mind that your hits will be in an array. You have to loop through the array and do stuff to your sub-cubes. Do your sub-cubes and large cube have different tags? Maybe change their color depending on their tag when you have them as a result of your RaycastAll. In principle, the RaycastAll should work.
answered Dec 29 '10 at 07:49 AM