Aim Down Sights Android

here is a script i am currently using how would i modify it to be used in android

var gun : Transform;
var nextPos = 0.0;
var nextField = 40.0;
var nextPos2 = -0.2;
var dampVelocity = 0.4;
var dampVelocity2 = 0.4;
var dampVelocity3 = 0.4;

function Update () {
   var newPos = Mathf.SmoothDamp(gun.transform.localPosition.x, nextPos, dampVelocity, .3);
   var newField = Mathf.SmoothDamp(Camera.main.fieldOfView, nextField, dampVelocity2, .3);
   var newPos2 = Mathf.SmoothDamp(gun.transform.localPosition.y, nextPos2, dampVelocity3, .3);

   gun.transform.localPosition.x = newPos;
   gun.transform.localPosition.y = newPos2;
   Camera.main.fieldOfView = newField;

   if (Input.GetButton("Fire2")) {
       //adjust viewpoint and gun position
       nextField = 40.0;
       nextPos = .05;
       nextPos2 = -0.15;

       //slow down turning and movement speed
       GetComponent("MouseLook").sensitivityX = 2;
       camera.main.GetComponent("MouseLook").sensitivityX = 2;
       camera.main.GetComponent("MouseLook").sensitivityY = 2;
   } else {
       //adjust viewpoint and gun position
       nextField = 60.0;
       nextPos = 0.45;
       nextPos2 = -0.4;

       //speed up turning and movement speed
       GetComponent("MouseLook").sensitivityX = 6;
       camera.main.GetComponent("MouseLook").sensitivityX = 6;
       camera.main.GetComponent("MouseLook").sensitivityY = 6;
   }
}

for example i have a button on the screen that is linked to the script but what function do i have to call to make the gun aim when the button on-screen is pressed

You’ll probably want to change this line:

if (Input.GetButton("Fire2"))

Instead, you could check a boolean which is toggled when the user presses or releases a button in your UI. There are quite a few resources around the net that could help you with that.

If you want a very fast solution, you could check if the user is touching the screen:

if (Input.touchCount > 0)