So I’m working on some code for my upcoming iphone fps game and I run into some problems, I get error messages in three places (I bolded the places where it says theres an error). The first ones error is “It is not possible to invoke an expression of type ‘UnityEngine.iPhoneTouch[ ]’.” Second and third ones are “An instance of type ‘UnityEngine.iPhoneTouch’ is required to access non static member ‘tapCount’.” Does anyone know what’s wrong?
var pauseMenu : GameObject;
var FB : GUITexture;
var RB : GUITexture;
var PB : GUITexture;
var limitedAmmo : float;
var AmmoLeft : float = 100.0;
var reload : boolean = false;
var count : float = 4.0;
function Update () {
for (var i = 0; i < count; i++){
[B]var touch : iPhoneTouch = iPhoneInput.touches(i);[/B]
var FBHit = FB.HitTest(touch.position);
var RBHit = RB.HitTest(touch.position);
var PBHit = PB.HitTest(touch.position);
}
if (PBHit){
if (Time.timeScale == 0.0){
Time.timeScale = 1.0;
pauseMenu.active = false;
}
else {
Time.timeScale = 0.0;
pauseMenu.active = true;
}
}
if(RBHit){
[B]if(iPhoneTouch.tapCount == 1){[/B]
if(reload){
limitedAmmo = 10.0;
AmmoLeft -= 10.0;
}
}
[B]else if(iPhoneTouch.tapCount == 2){[/B]
WeaponSwitch();
}
}
if(limitedAmmo < 10){
if(AmmoLeft > 0){
reload = true;
}
else{
reload = false;
}
}
if(FBHit){
fireBullet();
WaitForSeconds(1);
}
}
function WeaponSwitch(){
//switch weapon
}
function fireBullet(){
//fire bullet
}