Because I'm trying to stay in a good mood today.
And also, more people should post in JAVA!
This script allows you to set both a click, and double right click, while differentiating if the left was clicked first or the right. This recognition allows the user to set 10 or more key combinations with just the mouse alone!
It doesn't work perfect, for example, when holding left mouse, you cannot d-click the right mouse function. But, if you hold the mouse button, and slide transfer into a right button, it will detect and lock the right button when left mouse is released!
Please expand upon this, as I most certainly am. This community has given me a lot towards my project in code, and understanding, so I submit this to give a little back. Thank you all.
Enjoy
var checkKeyDown: float=0.0;
var checkKeyWasDown: boolean=false;
var checkClick:boolean=false;
var leftClickLock:boolean=false;
var rightClickLock:boolean=false;
var dClickR:boolean=false;
function input()
{if(Input.GetMouseButton(0))
{ //checkKeyDown=1.0;checkKeyWasDown=true;
if(!Input.GetMouseButton(0)){}
else { leftClickDown=true;
if(!rightClickLock)
{ leftClickLock=true;
if (Input.GetMouseButton(1)) {callFunction();}
else {attack();}}
else //rClick locked
{ if (Input.GetMouseButton(1)) {callFunction();
walk(10.0);}
else {rightClickLock=false;} }}}
else if (Input.GetMouseButton(1))
{ checkKeyDown=1.0;checkKeyWasDown=true;
if(!leftClickLock)
{ rightClickLock=true;
if (!Input.GetMouseButton(0))
{
if(checkClick){dClickR=true; callFunction();}
else {callFunction();}}}
else
{ leftClickLock=false; }}
else
{ leftClickDown=false;
rightClickLock=false;
leftClickLock=false;
if(checkKeyDown>0.0) {checkKeyDown-=10.5* Time.deltaTime; checkClick=true;}
else {checkKeyWasDown=false;checkClick=false; dClickR=false;} }
↧