public static Maggot Spawn(GameObject prefab, Vector3 position, GameObject target = null) { GameObject Maggot = GameObject.Instantiate(prefab); Maggot.transform.position = position; Maggot m = Maggot.GetComponent <Maggot>(); m.TARGET_HELPER = new TargetPlayer(); m.target = target; return(m); }
public void SpawnMaggot(Vector2 position) { if (isPlaying) { float x = Random.Range(-2f, 2f); float y = Random.Range(-2f, 2f); GameObject playerToChase = GetRandomPlayerToChase(); Maggot m = Maggot.Spawn(maggotPrefab, new Vector3(position.x + x, position.y + y, position.y + y), playerToChase); if (x < 0) { m.isLookinkRight = false; } } }