private void Split() { int n = (int)Mathf.Pow(slimeSize, 2); if (slimeSize <= 1) { n = 0; } for (int i = 0; i < n; i++) { Vector3 randVec = Quaternion.AngleAxis(Random.Range(0, 360), Vector3.forward) * Vector3.right; GameObject s = Instantiate(slime, this.transform.position + Random.Range(0, radii / 8) * randVec, Quaternion.Euler(0, 0, 0)) as GameObject; if (s.GetComponent <AItest>() != null) { AItest obj = s.GetComponent <AItest>(); obj.SetSlimeSize((slimeSize + Random.Range(-slimeSize / 2, slimeSize / 4)) / 2); s.tag = tag; } } Destroy(this.gameObject); //add a delayed destruction with shrink ani }
// Start is called before the first frame update void Start() { ai = gameObject.GetComponent <AItest>(); hp = gameObject.GetComponent <HealthSystem>(); }