// Update is called once per frame void Update() { sortList = gameObject.GetComponent <Octo_sort>(); if (target != null && target.gameObject.activeSelf == true) { //transform.LookAt(target); Vector3 targetDir = target.position - transform.position; float turnstep = 0.5f * Time.deltaTime; Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, turnstep, 0.0F); //Debug.DrawRay(transform.position, newDir, Color.red); transform.rotation = Quaternion.LookRotation(newDir); } else if (target == null || !target.gameObject.activeSelf == true) { Pool = sortList.passZone(); target = Pool.lockon(transform); } if (target == null) { target = forward; } transform.position = Vector3.MoveTowards(transform.position, target.position, step); }
//public bool turnoff; // Use this for initialization void Start() { if (spawn) { List = new GameObject[Sum]; Child = new GameObject[Sum2]; for (int i = 0; i < Sum; i++) { GameObject bullet = Instantiate(Orb, transform.position, transform.rotation) as GameObject; bullet.transform.SetParent(gameObject.transform); bullet.SetActive(false); List[i] = bullet; if (Orb2 != null) { GameObject bullet2 = Instantiate(Orb2, transform.position, transform.rotation) as GameObject; bullet2.transform.SetParent(transform); bullet2.SetActive(false); Child[i] = bullet2; } if (List[i].GetComponent <sorter>() != null) { note = List[i].GetComponent <sorter>(); note.set_List(Zonelist); note.setIDpool(idgiver); } if (List[i].GetComponent <Octo_sort>() != null) { note2 = List[i].GetComponent <Octo_sort>(); note2.setIDpool(idgiver); note2.set_List(Zonelist); } } } }