Hello …
I have one script which is repeatedly instantiating game object…
But after some condition match, i want to disable that script along with that object…
Script Code :
#pragma strict
public var enemy1Prefab : GameObject;
private var x : float;
private var y : float;
private var z : float;
private var scoreControllerScript : ScoreController;
private var gameControllerScript : GameController;
function Start () {
gameControllerScript = GameObject.Find("Main Camera").GetComponent("GameController");
scoreControllerScript = GameObject.Find("Main Camera").GetComponent("ScoreController");
InvokeRepeating("CreateRandomShip",0.01f,1.0f);
}
function Update () {
}
function CreateRandomShip()
{
x = Random.Range(-4.00f , 4.00f);
z = -6.72f;
y = 8.0f;
enemy1Prefab.transform.position = new Vector3(x , y , z);
Instantiate(enemy1Prefab,enemy1Prefab.transform.position,enemy1Prefab.transform.rotation);
if(gameControllerScript.gameStarted)
scoreControllerScript.ManageEnimies();
}
And Code which i have written to Disable Object and script is here :
if(GameObject.Find("Level6").active)
{
Debug.Log("level 6");
enemy1CreationScript = GameObject.Find("Level6").GetComponent("Enemy1Creation");
enemy1CreationScript.enabled = false;
GameObject.Find("Level6").active = !GameObject.Find("Level6").active;
}
By this code., My object and script both become disabled. I have Checked in Inspector panel…but then also it continuous to generate game object…
So what can be the reason behind this?
Please Help me to solve out this issue…
Thanks for Your Support and Help…