How to stop second finger from manipulating position of gui joystick

I have been working on a 3D mobile app in Unity3D, but have recently come across an issue. I have a joystick that makes my character walk. The joystick is a gui texture that. I have boundaries set so you can’t move the joystick all around the screen. It is set up so that when your finger moves outside the boundary, the joystick goes as far as it can go, and when you move your finger back, it continues moving along with your finger. This is good and all but I am going to set it up so that moving another finger along the right side of the screen rotates the camera. The issue happens when one finger is on the joystick and you put another finger on the right side of the screen. The joystick is manipulated by the second finger and even though it isn’t touching the joystick it manipulates the position of it. This only happens if a finger is already touching the joystick and you place another finger somewhere else on the screen. I can not figure out how to stop it! Any help will be GREATLY appreciated :slight_smile: here is my code

#pragma strict
var gui: GUITexture;
var pixelInsetPosResSet: boolean = true;
var playerCharacter: GameObject;

function Start ()
{
guiPixelInsetResSet();
gui.color.a=.1;
gui.transform.position.z=1;
}

function JoystickGUIMove ()
{
// Detecting Touch
if(Input.touchCount > 0 ){

    for(var i : int = 0; i < Input.touchCount; i++){

    var touch : Touch = Input.GetTouch(i);

    if( touch.phase == TouchPhase.Began && guiTexture.HitTest(touch.position))
    {
        pixelInsetPosResSet = false;
    }
if(pixelInsetPosResSet == false)
{
// Moving GUI and Character
    gui.pixelInset.x = touch.position.x+Screen.width/(-1.78);
    gui.pixelInset.y = touch.position.y+Screen.height/(-1.63);
    gui.color.a=.5;
    if(gui.pixelInset.y > Screen.height/(-3.5))
    {
        playerCharacter.transform.position.z = playerCharacter.transform.position.z+(8*Time.deltaTime);
    }
    else if(gui.pixelInset.y > Screen.height/(-2.6))
    {
        playerCharacter.transform.position.z = playerCharacter.transform.position.z+(2*Time.deltaTime);
    }
    else if(gui.pixelInset.y < Screen.height*(-.475))
    {
        playerCharacter.transform.position.z = playerCharacter.transform.position.z-(2*Time.deltaTime);
    }
    if(gui.pixelInset.x > Screen.width/(-2.4))
    {
        playerCharacter.transform.position.x = playerCharacter.transform.position.x+(2*Time.deltaTime);
    }
    if(gui.pixelInset.x > Screen.width/(-2.4) && gui.pixelInset.y > Screen.height/(-3.5))
    {
        playerCharacter.transform.position.x = playerCharacter.transform.position.x+(5*Time.deltaTime);
    }
    if(gui.pixelInset.x < Screen.width/(-2.1))
    {
        playerCharacter.transform.position.x = playerCharacter.transform.position.x-(2*Time.deltaTime);
    }
    if(gui.pixelInset.x < Screen.width/(-2.1) && gui.pixelInset.y > Screen.height/(-3.5))
    {
        playerCharacter.transform.position.x = playerCharacter.transform.position.x-(5*Time.deltaTime);
    }
    //Setting boundaries
    if(pixelInsetPosResSet == false)
    {
        if((touch.position.y+Screen.height/(-1.63)) > Screen.height/(-4.5)) 
        {
        gui.pixelInset.y = Screen.height/(-4.5);
        }
        if((touch.position.y+Screen.height/(-1.63)) < Screen.height*(-.5))
        {
        gui.pixelInset.y = Screen.height*(-.5);
        }
        if((touch.position.x+Screen.width/(-1.78)) > Screen.width/(-2.6))
        {
        gui.pixelInset.x = Screen.width/(-2.6);
        }
        if((touch.position.x+Screen.width/(-1.78)) < Screen.width*(-.5))
        {
        gui.pixelInset.x = Screen.width*(-.5);
        }
        }
        else
        {
            pixelInsetPosResSet = true;
            pixelInsetPositionReset();
        }
        }


pixelInsetPositionReset();

}   
}
}

function pixelInsetPositionReset ()
{
// Reseting Joystick position
for(var i : int = 0; i < Input.touchCount; i++){

var touch : Touch = Input.GetTouch(i);

if(touch.phase == TouchPhase.Ended)
{
    pixelInsetPosResSet = true;
    guiPixelInsetResSet();
}
}
}

function guiPixelInsetResSet ()
{
// Set width and height automatically
if (pixelInsetPosResSet == true)
{
gui.pixelInset.width=Screen.width/8.5;
gui.pixelInset.height=gui.pixelInset.width;
// Set position automatically
gui.pixelInset.x=Screen.width/(-2.25);
gui.pixelInset.y=Screen.height/(-2.35);
}
}

function Update ()
{
pixelInsetPositionReset();
gui.color.a=.1;
JoystickGUIMove ();
}