- Home /
two OnMouseDown function in the same obj, it's possible?
hi, sorry for my english :) my question is: can i have two differently "OnMouseDown functions" in the same object? if yes, how?
for example:
ty :)
Answer by Imankit · Jan 22, 2013 at 01:45 PM
Firstly you should use MouseButtonDown
And if you want to detect multiple touch use Input.Touch....
ya...ok...but if i use $$anonymous$$ouseButtonDown function can i use it for 2 different functions?
Input.Get$$anonymous$$ouseButtonDown(0) Input.Get$$anonymous$$ouseButtonDown(1)
You can use these two
Answer by Owen-Reynolds · Jan 22, 2013 at 04:44 PM
Say you can click on a bomb to either explode it, or to pick it up. How will the computer know which one they want to do? Once you figure that out, you can program it.
Exs: suppose shift-click picks it up. Then check for the shift key in mouseDown. Suppose you have to pick it up, plant it, then blow it up. Start each bomb's planted=false, set to true when you plant it, and have mouseDown explode only if planted=true.
Answer by -hiTo- · Jan 28, 2013 at 11:08 AM
What you want to do is place the if-clauses inside the OnMouseDown() function. This way you only need 1 :)
function OnMouseDown()
{
if (attivamazzoSM == true)
{
dadoFtrigger.TurnoF = true;
dado44obj.renderer.enabled = true
}
if (greenarrow == true)
{
dadomantrigg.TurnoM = true;
dado11obj.renderer.enabled = false;
}
}
To get the attivamazzoSM and the greenarrow bools to work, you need to make them fields in your class.
Your answer

Follow this Question
Related Questions
onMouseDown call function from other script 1 Answer
Making a var appear on click 1 Answer
function_parameters 1 Answer
I need "MainClass" 1 Answer
Invoke.Repeating doesn't really "care" about repeat time? 1 Answer