How to get mouse click event of an object's seen part?

Hi,

I’m using logic bricks and python code in order to animate objects. I need to generate an event whenever an object is clicked if mouse is clicked on the seen part of the object.

I’m using “mouse sensor” but it captures all click events.

How can I make the clicks only happen on the object generate an event,
or
how can I determine the click event is happened on the object('s seen part)

Thanks.

If I understand you correctly, all you should need is two mouse sensors connected to an AND controller like this:

If you’re using a Python script, you can just check when both sensors are positive within the script.

Oh, that’s simple! Thank you.

How could we get “mouse would be over if none of other objects existed” event?

I’m not sure I understand your question. If you’re asking how to get the object behind the object you clicked on, you’ll need to use a Python script that casts a ray from the point you clicked on along the same direction as the mouse ray and get the object it hits if there is one.

You understood correctly. Thanks for the suggestion. I’ll try it out and let you know. Thanks a lot!