Hello i’m trying to use OnMouseDown to make possible to interact with objects. So far it’s no real problem using it. But then i discovered one little thing that might force me to change all my script :
When i click with mouse left button it works fine, but doesn’t rect with the other mouse buttons. Is this an intended behaviour or a bug?
Yep, OnMouseDown() works only with left button. Checking for the pressure of a generic mouse button requires the implementation of an "overriding technique", that uses OnMouseOver(). A thing like this:
function OnMouseOver()
{
if (Input.GetMouseButtonDown(1)) //right button pressed
{
// OK, here you perform the action associated with right button
}
}
However, it seems to me that you have to perform the same action, independently from the button pressed: in this case, the script above is the same, just use a single if condition that includes all the desired buttons.