- Home /
Mouse events for object with character controller
I am trying to use OnMouseEnter and OnMouseExit in a script attached to an object with a character controller.
This doesn't appear to work. I cannot add a collider to the object without losing the character controller, which I need on the object.
I tried adding a box collider to a child of the object, but that didn't work either.
Does anyone know of a workaround to make this work?
Any help is greatly appreciated. -Larry
Answer by roamcel · Jan 02, 2012 at 01:43 PM
I don't seem to be able to -not- get this to work. This actually works with a single character controller standard collider, and with a different custom collider.
I'd suggest you start over from the example here: http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnMouseEnter.html
IMPORTANT: DOES NOT WORK ON IPHONE.
I will start over from that example, and see if that makes any difference. The object is really simple. Just a prefab containing a model with only a character controller attached to the prefab, and the script that I was trying to get the mouse events in.
The script contained only an On$$anonymous$$ouseEnter and On$$anonymous$$ouseExit with only debug.log lines in the body of the method, and they just never hit.
I will dig through the docs again, and see if I can figure out what I possibly could have done wrong.
Thanks for verifying that this should work, so I know I am not just spinning my wheels :)
-Larry