Search Unity

Hi everbody i did a pooling but now i don't know how can i move the enemies?

Discussion in 'Scripting' started by Ericmatheus, Oct 25, 2014.

  1. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68
    Thanks in advance,i tried to use the code editor but here it isn't working!

    static var headcannon : GameObject;
    var max : int;
    static var list = [];
    var timerepeat = 0.3 ;
    function Start () {
    headcannon = GameObject.Find ("/HeadCannon");
    max = 10;
    for(var list = 0; list < max; list++){
    {
    headcannon.SetActive(false);
    InvokeRepeating ("active",timerepeat,timerepeat);
    }
    }
    }
    function Update () {
    }
    function crear () {
    Instantiate (headcannon , transform.position , transform.rotation);
    }
    function active () {
    if (!headcannon.activeInHierarchy) // activeinhierarchy faz para os filhos tbm,por isso usa-lo
    {
    for(var list = 0; list < max; list++){
    {
    crear ();
    headcannon.SetActive (true);
    }
    }
    }
    }

    The headcannnon starts on a position that i determined,but i don't know how to move when the headcannon dies and i don't know how to acess the array,this is the script of headcannon
    var contadordedano : int;
    var guardar : int;
    function Start () {
    transform.position = Vector3 (56.02863,0.8328421,5.642716);
    }

    function Update () {
    }
    function OnCollisionEnter (collision : Collision ) {
    if (collision.gameObject.tag == "Bullet") {
    gameObject.SetActive (false);
    }
    }

    And i'm trying acess the array
    PoolScript2.list[0].transform.position = Vector3 (0,0,0);
     
  2. Diablo404

    Diablo404

    Joined:
    Mar 15, 2013
    Posts:
    136
    numberkruncher likes this.
  3. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68