HI guys this is the script that i write, i know that is not the best should be work but don’t ,or better work but to half script more or less and i don’t understand why.
The script :
var teamMan : GameObject;
var PlayerList1 : List.<GameObject> = new List.<GameObject>();
var PlayerList2 : List.<GameObject> = new List.<GameObject>();
var PlayerList3 : List.<GameObject> = new List.<GameObject>();
var PlayerListnoally : List.<GameObject> = new List.<GameObject>();
var limit : GameObject;
var distlimit : float;
var dist_team1_1 : float;
var dist_team1_2 : float;
var dist_team1_3 : float;
var dist_team2_1 : float;
var dist_team2_2 : float;
var dist_team2_3 : float;
var dist_team3_1 : float;
var dist_team3_2 : float;
var dist_team3_3 : float;
var dist_noteam_1 : float;
var dist_noteam_2 : float;
var dist_noteam_3 : float;
var dist_noteam_4 : float;
var dist_noteam_5 : float;
var dist_noteam_6 : float;
var dist_noteam_7 : float;
var dist_noteam_8 : float;
var dist_noteam_9 : float;
var team1aliveenear_1 : boolean = false;
var team1aliveenear_2 : boolean = false;
var team1aliveenear_3 : boolean = false;
var team2aliveenear_1 : boolean = false;
var team2aliveenear_2 : boolean = false;
var team2aliveenear_3 : boolean = false;
var team3aliveenear_1 : boolean = false;
var team3aliveenear_2 : boolean = false;
var team3aliveenear_3 : boolean = false;
var teamnoallyaliveenear_1 : boolean = false;
var teamnoallyaliveenear_2 : boolean = false;
var teamnoallyaliveenear_3 : boolean = false;
var teamnoallyaliveenear_4 : boolean = false;
var teamnoallyaliveenear_5 : boolean = false;
var teamnoallyaliveenear_6 : boolean = false;
var teamnoallyaliveenear_7 : boolean = false;
var teamnoallyaliveenear_8 : boolean = false;
var teamnoallyaliveenear_9 : boolean = false;
var enemynear : boolean = false;
function Start () {
teamMan = GameObject.Find("Managerteam");
}
function Update () {
PlayerList1 = teamMan.gameObject.GetComponent(manageteam).PlayerList1;
PlayerList2 = teamMan.gameObject.GetComponent(manageteam).PlayerList2;
PlayerList3 = teamMan.gameObject.GetComponent(manageteam).PlayerList3;
PlayerListnoally = teamMan.gameObject.GetComponent(manageteam).PlayerListnoally;
enemynear = this.gameObject.GetComponent(clicktomove).nearenemy;
distlimit = Vector3.Distance(this.transform.position,limit.transform.position);
if(PlayerList1.Count ==1)
{
dist_team1_1 = Vector3.Distance(this.transform.position,PlayerList1[0].transform.position);
}
if(PlayerList1.Count ==2)
{
dist_team1_1 = Vector3.Distance(this.transform.position,PlayerList1[0].transform.position);
dist_team1_2 = Vector3.Distance(this.transform.position,PlayerList1[1].transform.position);
}
if(PlayerList1.Count ==3)
{
dist_team1_1 = Vector3.Distance(this.transform.position,PlayerList1[0].transform.position);
dist_team1_2 = Vector3.Distance(this.transform.position,PlayerList1[1].transform.position);
dist_team1_3 = Vector3.Distance(this.transform.position,PlayerList1[2].transform.position);
}
//////////////////////////////////////////////////
if(PlayerList2.Count ==1)
{
dist_team2_1 = Vector3.Distance(this.transform.position,PlayerList2[0].transform.position);
}
if(PlayerList2.Count ==2)
{
dist_team2_1 = Vector3.Distance(this.transform.position,PlayerList2[0].transform.position);
dist_team2_2 = Vector3.Distance(this.transform.position,PlayerList2[1].transform.position);
}
if(PlayerList2.Count ==3)
{
dist_team2_1 = Vector3.Distance(this.transform.position,PlayerList2[0].transform.position);
dist_team2_2 = Vector3.Distance(this.transform.position,PlayerList2[1].transform.position);
dist_team2_3 = Vector3.Distance(this.transform.position,PlayerList2[2].transform.position);
}
/////////////////////////////////////////////////
if(PlayerList3.Count ==1)
{
dist_team3_1 = Vector3.Distance(this.transform.position,PlayerList3[0].transform.position);
}
if(PlayerList3.Count ==2)
{
dist_team3_1 = Vector3.Distance(this.transform.position,PlayerList3[0].transform.position);
dist_team3_2 = Vector3.Distance(this.transform.position,PlayerList3[1].transform.position);
}
if(PlayerList3.Count ==3)
{
dist_team3_1 = Vector3.Distance(this.transform.position,PlayerList3[0].transform.position);
dist_team3_2 = Vector3.Distance(this.transform.position,PlayerList3[1].transform.position);
dist_team3_3 = Vector3.Distance(this.transform.position,PlayerList3[2].transform.position);
}
//////////////////////////////////////////////////
if(PlayerListnoally.Count ==1)
{
dist_noteam_1 = Vector3.Distance(this.transform.position,PlayerListnoally[0].transform.position);
}
if(PlayerListnoally.Count ==2)
{
dist_noteam_1 = Vector3.Distance(this.transform.position,PlayerListnoally[0].transform.position);
dist_noteam_2 = Vector3.Distance(this.transform.position,PlayerListnoally[1].transform.position);
}
if(PlayerListnoally.Count ==3)
{
dist_noteam_1 = Vector3.Distance(this.transform.position,PlayerListnoally[0].transform.position);
dist_noteam_2 = Vector3.Distance(this.transform.position,PlayerListnoally[1].transform.position);
dist_noteam_3 = Vector3.Distance(this.transform.position,PlayerListnoally[2].transform.position);
}
if(PlayerListnoally.Count ==4)
{
dist_noteam_1 = Vector3.Distance(this.transform.position,PlayerListnoally[0].transform.position);
dist_noteam_2 = Vector3.Distance(this.transform.position,PlayerListnoally[1].transform.position);
dist_noteam_3 = Vector3.Distance(this.transform.position,PlayerListnoally[2].transform.position);
dist_noteam_4 = Vector3.Distance(this.transform.position,PlayerListnoally[3].transform.position);
}
if(PlayerListnoally.Count ==5)
{
dist_noteam_1 = Vector3.Distance(this.transform.position,PlayerListnoally[0].transform.position);
dist_noteam_2 = Vector3.Distance(this.transform.position,PlayerListnoally[1].transform.position);
dist_noteam_3 = Vector3.Distance(this.transform.position,PlayerListnoally[2].transform.position);
dist_noteam_4 = Vector3.Distance(this.transform.position,PlayerListnoally[3].transform.position);
dist_noteam_5 = Vector3.Distance(this.transform.position,PlayerListnoally[4].transform.position);
}
if(PlayerListnoally.Count ==6)
{
dist_noteam_1 = Vector3.Distance(this.transform.position,PlayerListnoally[0].transform.position);
dist_noteam_2 = Vector3.Distance(this.transform.position,PlayerListnoally[1].transform.position);
dist_noteam_3 = Vector3.Distance(this.transform.position,PlayerListnoally[2].transform.position);
dist_noteam_4 = Vector3.Distance(this.transform.position,PlayerListnoally[3].transform.position);
dist_noteam_5 = Vector3.Distance(this.transform.position,PlayerListnoally[4].transform.position);
dist_noteam_6 = Vector3.Distance(this.transform.position,PlayerListnoally[5].transform.position);
}
if(PlayerListnoally.Count ==7)
{
dist_noteam_1 = Vector3.Distance(this.transform.position,PlayerListnoally[0].transform.position);
dist_noteam_2 = Vector3.Distance(this.transform.position,PlayerListnoally[1].transform.position);
dist_noteam_3 = Vector3.Distance(this.transform.position,PlayerListnoally[2].transform.position);
dist_noteam_4 = Vector3.Distance(this.transform.position,PlayerListnoally[3].transform.position);
dist_noteam_5 = Vector3.Distance(this.transform.position,PlayerListnoally[4].transform.position);
dist_noteam_6 = Vector3.Distance(this.transform.position,PlayerListnoally[5].transform.position);
dist_noteam_7 = Vector3.Distance(this.transform.position,PlayerListnoally[6].transform.position);
}
if(PlayerListnoally.Count ==8)
{
dist_noteam_1 = Vector3.Distance(this.transform.position,PlayerListnoally[0].transform.position);
dist_noteam_2 = Vector3.Distance(this.transform.position,PlayerListnoally[1].transform.position);
dist_noteam_3 = Vector3.Distance(this.transform.position,PlayerListnoally[2].transform.position);
dist_noteam_4 = Vector3.Distance(this.transform.position,PlayerListnoally[3].transform.position);
dist_noteam_5 = Vector3.Distance(this.transform.position,PlayerListnoally[4].transform.position);
dist_noteam_6 = Vector3.Distance(this.transform.position,PlayerListnoally[5].transform.position);
dist_noteam_7 = Vector3.Distance(this.transform.position,PlayerListnoally[6].transform.position);
dist_noteam_8 = Vector3.Distance(this.transform.position,PlayerListnoally[7].transform.position);
}
if(PlayerListnoally.Count ==9)
{
dist_noteam_1 = Vector3.Distance(this.transform.position,PlayerListnoally[0].transform.position);
dist_noteam_2 = Vector3.Distance(this.transform.position,PlayerListnoally[1].transform.position);
dist_noteam_3 = Vector3.Distance(this.transform.position,PlayerListnoally[2].transform.position);
dist_noteam_4 = Vector3.Distance(this.transform.position,PlayerListnoally[3].transform.position);
dist_noteam_5 = Vector3.Distance(this.transform.position,PlayerListnoally[4].transform.position);
dist_noteam_6 = Vector3.Distance(this.transform.position,PlayerListnoally[5].transform.position);
dist_noteam_7 = Vector3.Distance(this.transform.position,PlayerListnoally[6].transform.position);
dist_noteam_8 = Vector3.Distance(this.transform.position,PlayerListnoally[7].transform.position);
dist_noteam_9 = Vector3.Distance(this.transform.position,PlayerListnoally[8].transform.position);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(dist_team1_1 < distlimit)
{
if(PlayerList1[0].gameObject.GetComponent(healthbar).health >0)
{
team1aliveenear_1 = true;
}
else
{
team1aliveenear_1 = false;
}
}
else if(dist_team1_1 > distlimit)
{
team1aliveenear_1 = false;
}
if(dist_team1_2 < distlimit)
{
if(PlayerList1[1].gameObject.GetComponent(healthbar).health >0)
{
team1aliveenear_2 = true;
}
else
{
team1aliveenear_2 = false;
}
}
else if(dist_team1_2 > distlimit)
{
team1aliveenear_2 = false;
}
if(dist_team1_3 < distlimit )
{
if(PlayerList1[2].gameObject.GetComponent(healthbar).health >0)
{
team1aliveenear_3 = true;
}
else
{
team1aliveenear_3 = false;
}
}
else if(dist_team1_3 > distlimit)
{
team1aliveenear_3 = false;
}
////WORKS UP THIS LINE
//////////////////////////////////////////////////////////
////DON'T WORKS UNDER THIS LINE
if(dist_team2_1 < distlimit)
{
if(PlayerList2[0].gameObject.GetComponent(healthbar).health >0)
{
team2aliveenear_1 = true;
}
else
{
team2aliveenear_1 = false;
}
}
else if(dist_team2_1 > distlimit)
{
team2aliveenear_1 = false;
}
if(dist_team2_2 < distlimit)
{
if(PlayerList2[1].gameObject.GetComponent(healthbar).health >0)
{
team2aliveenear_2 = true;
}
else
{
team2aliveenear_2 = false;
}
}
else if(dist_team2_2 > distlimit)
{
team2aliveenear_2 = false;
}
if(dist_team2_3 < distlimit )
{
if(PlayerList2[2].gameObject.GetComponent(healthbar).health >0)
{
team2aliveenear_3 = true;
}
else
{
team2aliveenear_3 = false;
}
}
else if(dist_team2_3 > distlimit)
{
team2aliveenear_3 = false;
}
/////////////////////////////////////////////////////////////////
if(dist_team3_1 < distlimit)
{
if(PlayerList3[0].gameObject.GetComponent(healthbar).health >0)
{
team3aliveenear_1 = true;
}
else
{
team3aliveenear_1 = false;
}
}
else if(dist_team3_1 > distlimit)
{
team3aliveenear_1 = false;
}
if(dist_team3_2 < distlimit)
{
if(PlayerList3[1].gameObject.GetComponent(healthbar).health >0)
{
team3aliveenear_2 = true;
}
else
{
team3aliveenear_2 = false;
}
}
else if(dist_team3_2 > distlimit)
{
team3aliveenear_2 = false;
}
if(dist_team3_3 < distlimit )
{
if(PlayerList3[2].gameObject.GetComponent(healthbar).health >0)
{
team3aliveenear_3 = true;
}
else
{
team3aliveenear_3 = false;
}
}
else if(dist_team3_3 > distlimit)
{
team3aliveenear_3 = false;
}
//////////////////////////////////////////////////////////////////////////
if(dist_noteam_1 < distlimit)
{
if(PlayerListnoally[0].gameObject.GetComponent(healthbar).health >0)
{
teamnoallyaliveenear_1 = true;
}
else
{
teamnoallyaliveenear_1 = false;
}
}
else if(dist_noteam_1 > distlimit)
{
teamnoallyaliveenear_1 = false;
}
//**********************************************
if(dist_noteam_2 < distlimit)
{
if(PlayerListnoally[1].gameObject.GetComponent(healthbar).health >0)
{
teamnoallyaliveenear_2 = true;
}
else
{
teamnoallyaliveenear_2 = false;
}
}
else if(dist_noteam_2 > distlimit)
{
teamnoallyaliveenear_2 = false;
}
//**********************************************
if(dist_noteam_3 < distlimit)
{
if(PlayerListnoally[2].gameObject.GetComponent(healthbar).health >0)
{
teamnoallyaliveenear_3 = true;
}
else
{
teamnoallyaliveenear_3 = false;
}
}
else if(dist_noteam_3 > distlimit)
{
teamnoallyaliveenear_3 = false;
}
//**********************************************
if(dist_noteam_4 < distlimit)
{
if(PlayerListnoally[3].gameObject.GetComponent(healthbar).health >0)
{
teamnoallyaliveenear_4 = true;
}
else
{
teamnoallyaliveenear_4 = false;
}
}
else if(dist_noteam_4 > distlimit)
{
teamnoallyaliveenear_4 = false;
}
//**********************************************
if(dist_noteam_5 < distlimit)
{
if(PlayerListnoally[4].gameObject.GetComponent(healthbar).health >0)
{
teamnoallyaliveenear_5 = true;
}
else
{
teamnoallyaliveenear_5 = false;
}
}
else if(dist_noteam_5 > distlimit)
{
teamnoallyaliveenear_5 = false;
}
//**********************************************
if(dist_noteam_6 < distlimit)
{
if(PlayerListnoally[5].gameObject.GetComponent(healthbar).health >0)
{
teamnoallyaliveenear_6 = true;
}
else
{
teamnoallyaliveenear_6 = false;
}
}
else if(dist_noteam_6 > distlimit)
{
teamnoallyaliveenear_6 = false;
}
//**********************************************
if(dist_noteam_7 < distlimit)
{
if(PlayerListnoally[6].gameObject.GetComponent(healthbar).health >0)
{
teamnoallyaliveenear_7 = true;
}
else
{
teamnoallyaliveenear_7 = false;
}
}
else if(dist_noteam_7 > distlimit)
{
teamnoallyaliveenear_7 = false;
}
//**********************************************
if(dist_noteam_8 < distlimit)
{
if(PlayerListnoally[7].gameObject.GetComponent(healthbar).health >0)
{
teamnoallyaliveenear_8 = true;
}
else
{
teamnoallyaliveenear_8 = false;
}
}
else if(dist_noteam_8 > distlimit)
{
teamnoallyaliveenear_8 = false;
}
//**********************************************
if(dist_noteam_9 < distlimit)
{
if(PlayerListnoally[8].gameObject.GetComponent(healthbar).health >0)
{
teamnoallyaliveenear_9 = true;
}
else
{
teamnoallyaliveenear_9 = false;
}
}
else if(dist_noteam_9 > distlimit)
{
teamnoallyaliveenear_9 = false;
}
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
if(this.gameObject.GetComponent(clicktomove).ally1)
{
if(!this.gameObject.GetComponent(clicktomove).tryhide)
{
if(team2aliveenear_1 || team2aliveenear_2 || team2aliveenear_3 || team3aliveenear_1 || team3aliveenear_2 || team3aliveenear_3 ||
teamnoallyaliveenear_1 || teamnoallyaliveenear_2 || teamnoallyaliveenear_3 || teamnoallyaliveenear_4 || teamnoallyaliveenear_5 ||
teamnoallyaliveenear_6 || teamnoallyaliveenear_7 || teamnoallyaliveenear_8 || teamnoallyaliveenear_9)
{
this.gameObject.GetComponent(clicktomove).nearenemy = true;
}
}
else
{
this.gameObject.GetComponent(clicktomove).nearenemy = false;
}
}
////////////////////////////////////////
if(this.gameObject.GetComponent(clicktomove).ally2)
{
if(!this.gameObject.GetComponent(clicktomove).tryhide)
{
if(team1aliveenear_1 || team1aliveenear_2 || team1aliveenear_3 || team3aliveenear_1 || team3aliveenear_2 || team3aliveenear_3 ||
teamnoallyaliveenear_1 || teamnoallyaliveenear_2 || teamnoallyaliveenear_3 || teamnoallyaliveenear_4 || teamnoallyaliveenear_5 ||
teamnoallyaliveenear_6 || teamnoallyaliveenear_7 || teamnoallyaliveenear_8 || teamnoallyaliveenear_9)
{
this.gameObject.GetComponent(clicktomove).nearenemy = true;
}
}
else
{
this.gameObject.GetComponent(clicktomove).nearenemy = false;
}
}
//////////////////////////////////////////
if(this.gameObject.GetComponent(clicktomove).ally3)
{
if(!this.gameObject.GetComponent(clicktomove).tryhide)
{
if(team1aliveenear_1 || team1aliveenear_2 || team1aliveenear_3 || team2aliveenear_1 || team2aliveenear_2 || team2aliveenear_3 ||
teamnoallyaliveenear_1 || teamnoallyaliveenear_2 || teamnoallyaliveenear_3 || teamnoallyaliveenear_4 || teamnoallyaliveenear_5 ||
teamnoallyaliveenear_6 || teamnoallyaliveenear_7 || teamnoallyaliveenear_8 || teamnoallyaliveenear_9)
{
this.gameObject.GetComponent(clicktomove).nearenemy = true;
}
}
else
{
this.gameObject.GetComponent(clicktomove).nearenemy = false;
}
}
//////////////////////////////////////////////
if(this.gameObject.GetComponent(clicktomove).noally)
{
if(!this.gameObject.GetComponent(clicktomove).tryhide)
{
if(team1aliveenear_1 || team1aliveenear_2 || team1aliveenear_3 || team2aliveenear_1 || team2aliveenear_2 || team2aliveenear_3 ||
team3aliveenear_1 || team3aliveenear_2 || team3aliveenear_3)
{
this.gameObject.GetComponent(clicktomove).nearenemy = true;
}
}
else
{
this.gameObject.GetComponent(clicktomove).nearenemy = false;
}
}
Hope in a help with this issue.
Thanks and cheers
P.S Ah! i’m italian so please sorry for my english