- Home /
Question by
Ulfr · Jul 06, 2017 at 03:33 AM ·
collisioncollider2donmouseenter
How do I get onmouseenter to trigger even if another collider is blocking th?
Pretty much the title. I have one object changes sprite depending on whether the cursor is above it or not, but I also want it to trigger even if there is another object above it.
Comment
Well you could just use layers, and ins$$anonymous$$d of onmouseenter, you use a click and raycast method like this, and just define the layer to ignore in the raycast.
if ( Input.Get$$anonymous$$ouseButtonDown (0))
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if ( Physics.Raycast (ray,out hit,100.0f, layeToIgnore))
{
$$anonymous$$yClickableObject $$anonymous$$CO;
if ($$anonymous$$CO = hit.transform.GetComponent<$$anonymous$$yClickableObject>())
{
$$anonymous$$CO.ClickObject();
}
}
}
Your answer
