Hey all, for most of my time working with Unity iPhone I have been testing my game using a 3G iPhone so I scripted all my touch inputs for its resolution. But recently I have had people test it using iPhone 4 and the iPad and they have run into touch input problems. I would like some help in figuring out the best way of modifying this script to work similarly on all iDevices.:
for (var touch : Touch in Input.touches ){
var count = Input.touchCount;
//gets the degree rotation of z axis and flips the direction
theDeg = controllerDirection.transform.rotation.eulerAngles.z * -1;
//sets the y rotation of the player to the z rotation of the controller
thisTransform.transform.rotation.eulerAngles.y = theDeg;
//gets values for the default resolution and modify screen width/height to flip in direction
var screenX = Screen.width * -1;
var screenY = Screen.height * -1;
//gives the coordinates of player touch with middle of screen being (0, 0)
touchP = Vector2 (screenX + touch.position.x + 240, screenY + touch.position.y + 160 );
//gets the position limits for the controls
cTouch = touchP.x > -240 touchP.x < -100 touchP.y > -140 touchP.y < -20;
aTouch = touchP.x > 120 touchP.x < 220 touchP.y > -170 touchP.y < -30;
mTouch = touchP.x > -100 touchP.x < 100 touchP.y > -100 touchP.y < 100;
//checks to see if player is touching within the control coordinates then initiates movement
if (cTouch){
if (count == 1){
midTouch = false;
}
if (midTouch == false isAttacking == false){
character.SimpleMove(transform.forward * moveSpeedDelta);
isMoving = true;
if ((animation["att1"].normalizedTime > .8) || (animation["att2"].normalizedTime > .7) ||(animation.IsPlaying ("att3"))){
moveSpeedDelta = 0;
theDeg = controllerDirection.transform.rotation.eulerAngles.z * 0;
}else{
moveSpeedDelta = moveSpeed;
theDeg = controllerDirection.transform.rotation.eulerAngles.z * -1;
}
}
}else{
isMoving = false;
}
//checks to see if player is touching within the coordinates then initiates actions
if (aTouch) { //5th - 2
showWeapon = true;
idleTimeWindow = idleTimeDelta;
idleType = 2;
idleTiming = true;
isMoving = false;
isAttacking = true;
if (state == 0){
if (!animation.IsPlaying("att1") !animation.IsPlaying("att2") !animation.IsPlaying("att3")){
animType = 1;
state = 1;
}else if (animation.IsPlaying("att1")){
idleTimeWindow = idleTimeDelta;
idleType = 2;
animType = 2;
state = 1;
}else if (animation.IsPlaying("att2")){
idleTimeWindow = idleTimeDelta;
idleType = 2;
animType = 3;
}
state = 1;
}
}
//used to check touch in middle of screen
if (mTouch) { //6th - 2
showWeapon = false;
midTouch = true;
animType = 4;
// reference the Soul Gameobjects
soul = GameObject.FindGameObjectsWithTag("Collectible");
//cycle search for all Soul GameObjects then calls the Absorb Soul script
for(var go in soul) {
var abs : AbsorbSoul = go.GetComponent( AbsorbSoul );
abs.Absorb();
}
}
}
}
Help would be appreciated, thanks.