- Home /
How to check if your cursor is over a cube.
Im making a new game, I just started making it about 30 minutes ago and I'm already stuck. It's a little more complex then the title says. I need to check if my cursor is over any of the 6 faces of the cube. So for example: "If my cursor is entering the top-face of the cube..." and then I will have it change texture so that it looks highlighted and all that stuff :)
Thanks in advance!
Answer by DaveA · Jul 31, 2011 at 12:37 AM
If it needs to react differently to each face, you need to make it from 6 different meshes, and easiest to use 6 different GameObjects. You could just use the Plane primitive (x6 and move/rotate them into place) but that gives you more triangles than you need. There's an add-on that makes simpler planes, or just model one in Blender.
Anyway, put a mesh collider on it (using same mesh, the plane), set the collider setting to 'is trigger' and implement the OnMouseOver() function in a script you attach to that gameobject containing the face.
If you really just need 'over any face of the cube' then you can use the standard Box and use a Box collider too, same idea as above.
Your answer
Follow this Question
Related Questions
mouse Input Instantiate 0 Answers
how to stop mouse going out of the screen ? 9 Answers
Invisible mouse script? 1 Answer
Locking the mouse cursor without it centering after unlocking it? 0 Answers
where should i put this script 2 Answers