예제 #1
0
    // Use this for initialization
    void Start()
    {
        //Creates instance of vehicle and activates it.
        spawnMeInst = (GameObject)Instantiate(spawnMe);
        spawnMeInst.SetActive(false);

        //Inits array on amount of childer the waypoints GameObject has, then fills targetWaypoints with them.
        wayPoints = new GameObject[targetWaypoints.transform.childCount];
        int i = 0;

        foreach (Transform child in targetWaypoints.transform)
        {
            wayPoints[i] = child.gameObject;
            i++;
        }

        //Inits the nav controller.
        navC        = spawnMeInst.GetComponent <NavController>();
        navC.target = targetWaypoints.transform;
        navC.setWaypoints(wayPoints);

        //Sets the instance to the correct position.
        spawnMeInst.transform.position = this.transform.position;
        spawnMeInst.transform.rotation = this.transform.rotation;
    }
예제 #2
0
    /// <summary>
    /// Force spawn on this spawner.
    /// </summary>
    public void spawn()
    {
        GameObject spawnee = (GameObject)Instantiate(spawnMeInst);

        spawnee.SetActive(true);
        NavController nav = spawnee.GetComponent <NavController>();

        nav.setWaypoints(wayPoints);
        nav.spawner = this;
    }