Answer the question
In order to leave comments, you need to log in
How to determine which mouse button was pressed?
There is a script which is hung up on object. The script has an OnMouseDown() method. It fires when you click on the object's collider, but how do you determine which mouse button was used to click?
Answer the question
In order to leave comments, you need to log in
Replace it with Update with Input check
As an example in the documentation)
https://docs.unity3d.com/ScriptReference/Input.Get...
And send a ray to the collider, check which object it hit.
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, 100))
print("Hit something!");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question