- Home /
How to press 2 buttons at the same time
I've one button to aim down sights, and one to shoot.. oh and this is a android project when I click on the shoot button, it works, however when I hold down the aim down sights button, the shoot button doesn't work :( what is wrong with my scripts??
this is attatched to the shoot button:
function Update () {
if (Input.touchCount == 1){
var touch: Touch = Input.touches[0]; if(touch.phase == TouchPhase.Began && guiTexture.HitTest(touch.position)){
print("worked");
GameObject.Find("M40A11").SendMessage("shoot"); } } }
and this is attatched to the aimDownSights button:
if (iPhoneInput.touchCount ==1){
var currentTouch:iPhoneTouch = iPhoneInput.touches[0];
if(currentTouch.phase == iPhoneTouchPhase.Began && guiTexture.HitTest(currentTouch.position)){
isAiming = true;
}
if(currentTouch.phase == iPhoneTouchPhase.Ended){
isAiming = false;
scopeTexture.gameObject.active = false;
cameraa.camera.cullingMask = mask;
}
}
thats not the whole script because it's long.
Please reply! :( :( :(
Answer by skoandi · Jul 09, 2012 at 08:08 PM
I SOLVED IT!! :D
I by misstake I used this:
if (Input.touchCount>0) { for (var touch : Touch in Input.touches) { if (touch.phase == TouchPhase.Began && guiTexture.HitTest(touch.position)) {
//this can handle many touches :D
}
}
}
I'm not understanding how this fixed it!!! would you be able to provide more code? I'm struggling to figure this thing out!