Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm detecting the mouse clicks if the click is happened over the collider but i dont't want to fire mouse click if it is on the trigger object. How to i do this. Anyone give me a suggestion.

Thank you!

share|improve this question
    
How are you detecting which object was clicked? – SanSolo Nov 18 '15 at 4:46
    
I'm using OnTriggerStay2D() method and some boolean variables to detect the mouse click... void OnTriggerStay2D (Collider2D col) { if (gameObject.name == "elephant" && col.gameObject.name == "elephant 1") { canShow = true; if (canClick) { Show (col.gameObject); ObjectActivate ("book1"); } } canClick will become true if the object on the trigger and the mouse is clicked. But i don't want user to click on the trigger object. – Albertkaruna Nov 18 '15 at 4:59
    
Where is this Collision detection script attached? – SanSolo Nov 18 '15 at 5:29
    
Gameobject that i am picking. Here it is 'elephant'. – Albertkaruna Nov 18 '15 at 5:30
1  
Ok. How are you detecting Mouse clicks? – SanSolo Nov 18 '15 at 5:37

How to detect clicks on object? . This is a question I had asked. The proper way to detect mouse clicks is to use RayCasting, RayCast2D for 2D. While Raycasting, you can specify layermask, which let's you ignore objects which you want to ignore.

The second answer on the aforementioned question provides a solution for 2D.

share|improve this answer
    
Yeah it's good but how do i detect collision when the object collid with another object. Because here we can't use default OnTriggerXXX() method.... – Albertkaruna Nov 18 '15 at 5:33
    
Your question is not clear. In your post, you asked : "I'm detecting the mouse clicks" . This answers how to detect mouse clicks. If you want to know how to detect collision between two objects, post a new question. – SanSolo Nov 18 '15 at 5:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.