|
I have a model with a rigidbody attached and I change the material in OnMouseEnter and OnMouseExit. It works correctly when I don't hold the mouse button down, but when I do have any mouse button held down and I drag over the object it flickers. Is this a known bug or am I doing something wrong? Edit: added code
(comments are locked)
|
|
It's a bug that happens if you're using OnGUI. As a side note, you don't need a rigidbody if you're just using OnMouseEnter/Exit, all you need is a collider. If you are using it as a moving object under physics control, never mind. Thanks, if it's a known bug I can just live with it for now. I'm not using the rigidbody for anything except the mouse collisions. If i remove the rigid body OnMouseEnter and OnMouseExit no longer get fired.
Dec 17 '10 at 03:55 AM
_Petroz
Rigidbodies are only necessary for objects in motion under physics control. OnMouseEnter and OnMouseExit depend only on a collider present, not a rigidbody. They do fire without a rigidbody.
Dec 17 '10 at 05:09 AM
Eric5h5
That isn't the behaviour I'm seeing. I have appended the code to my post. Here is a demonstration: http://www.youtube.com/watch?v=FjM8fqAmVdo
Dec 18 '10 at 11:25 AM
_Petroz
@Petroz: Aha, the problem is that you're using a compound collider. This isn't a bug. By design, compound colliders act as a single collider when you add a rigidbody to the parent, and therefore only the root object will react to OnMouseEnter. If you add a rigidbody to the child, you break the compound collider; as the docs say, you should not parent rigidbodies together. So the rigidbodies have nothing to do with OnMouseEnter, but are rather changing how the colliders themselves work in the case of parent/child.
Dec 18 '10 at 04:04 PM
Eric5h5
(comments are locked)
|
|
Do you have something inside any of the OnMouseDown/Over/Drag functions?
(comments are locked)
|
