I am making a fps game for windows phone. I have an Aim Down Sight script for my gun. It works fine with Input.GetMouseButton, but when I try and use the GUI function instead, it draws it but does nothing. Here is the original script:
#pragma strict
var Aim : boolean = false; var Cam : GameObject;
function Update () { if(Input.GetMouseButtonDown(0)){ Aim = true; if(Aim == true){ Cam.active = true; } }
if(Input.GetMouseButtonUp(0)){ Aim = true; if(Aim){ Cam.active = false; }
}
}
Here is the script with GUI Functions:
enter code here#pragma strict
var Aim : boolean = false; var Cam : GameObject;
function OnGUI () { if(GUI.Button (Rect (20,40,80,20), "ADS")){
Aim = true; if(Aim == true){ Cam.active = true; } }
if(GUI.Button (Rect (20,40,80,20), "ADS")){
Aim = true; if(Aim){ Cam.active = false; }
}
}
I am much less confident with GUI input. I keep pressing it but it doesn’t ADS like the MouseButton(0). I’d much rather have this as a GUI functionality, as it plays weird on my phone as a tap.
Thanks.
BenDy Games, Game Development For Windows Phone 8