Hello everyone, how to limit the range of using the OnMouseDown method, I call it when the player clicks on an item
Can you elaborate on what you mean by “limit the range” of it?
i just use google translate, sorry
https://www.youtube.com/watch?v=eEWjkAYTd8c
Two options I’d look at:
- Add some code to check the distance to the camera inside OnMouseDown. something like
(transform.position - Camera.main.transform.position).magnitude < threshold - Replace OnMouseDown with a
Physics.Raycastwith a set distance.
1 Like
ohh, thank you very much