- Home /
Question by
huglojsk · Feb 02, 2014 at 07:25 PM ·
controlsonguisimplemultitouch
Transform GUIbuttons to multitouch GUI
Hello!
I am trying to make a simple GUI with three buttons; Right, Left and Jump. I learned how to use the OnGUI buttons only to learn that they don't support multi-touch (more than one button pressed at a time). I have been searching around for a while now to find a solution to this but have only found C# code and a lot of other over-complicated Javascript scripts.
I would be extremely happy if someone could explain how to transform the following script from OnGUI() to multitouch. (Javascript)
function OnGUI() {
if(GUI.RepeatButton(Rect(1080,610,100,100),"Right")) {
rigidbody.AddForce(Vector3.right * speed);
}
if(GUI.RepeatButton (Rect(970,610,100,100),"Left")) {
rigidbody.AddForce(Vector3.left * speed);
}
if(GUI.RepeatButton (Rect(10,610,100,100),"Jump") && grounded == 0) {
rigidbody.AddForce(Vector3.up * jumpHeight, ForceMode.Impulse);
grounded = 1;
}
}
Thanks,
Adam
Comment