How to ignore mouse click at background layers or objects?
I'm developing simple fix it kind of games. Here if i clicked at the object it will instantiate new layer in front of the background layer. But the problem is when i click on the top layer the click also affects the background layer. How to avoid it. I used layer based collision and collider on the top layer but no use. Please anyone give me any idea... Thanks in advance.
Answer by SpiderJones · Mar 27, 2021 at 01:19 AM
Hi, you can do this...
[SerializeField] private LayerMask inputLayerMask;
private void Start()
{
Camera.main.eventMask = inputLayerMask;
}
Then in the game object's inspector set what layer mask, or masks, you want to receive mouse input.
Your answer
Follow this Question
Related Questions
Displaying an item's description on screen using the GUI (Resident Evil style) 0 Answers
controlling objects with a character controlled by a nav mesh agent 0 Answers
How I can move a object with movements of my head? 0 Answers
La touche "Fire1" ne marche pas 2 Answers
how can i move my gameobject on mouse click by script?? 2 Answers