- Home /
Triggered box works automatically for OnMouseEnter for objects inside.
So I was testing something simple that I will develop into something more complex. I want to get working OnMouseEnter only when the player is inside a box trigger. I made a couple of boxes and set it to change the color, the funny thing is that it works how I want it to work just by putting the boxes inside the trigger, no script, no connection. I'm new to Unity. Is this the best way to do what I want?
Can you elaborate further? Are you trying to simulate your player's control through mouse input?
I made a box which shows up a GUITexture saying Turn Light On, when my mouse goes over the box, and says Turn Light Off if the Light is already on and viceversa. I ckick on the box to swith the light on and off. The GUITexture appears when my cursor is over the box and changes to the other texture when I click on the box, etc. Works great. The idea is later change the box into a lamp shape and put the light on it. But I don't want the player to be able to turn the light on and of, or show the GUITexture if he is not close enough, that would be inside a collider. So I put a collider and the box inside. When I was trying to figure out, how to code it, I noticed that it just worked right away. I don't know if it's a bug of if it's a solution, or if is a lose end, ir works but will give me problems.