public override void Fire() { if (IEnemy.enemys.Count > 0) { target = BarrageUtil.RandomFecthFromList <IEnemy>(IEnemy.enemys).gameObject; } base.Fire(); }
public void OnEnable() { GameObject tmpTrail = Instantiate(trail); UnityTool.Attach(gameObject, tmpTrail, Vector3.zero); if (IEnemy.enemys.Count > 0) { target = BarrageUtil.RandomFecthFromList <IEnemy>(IEnemy.enemys).gameObject; } }
// Update is called once per frame void Update() { if (target == null) { if (IEnemy.enemys.Count > 0) { target = BarrageUtil.RandomFecthFromList <IEnemy>(IEnemy.enemys).gameObject; } base.Update(); return; } transform.forward = Vector3.Slerp(transform.forward, target.transform.position - transform.position, 0.5f / Vector3.Distance(transform.position, target.transform.position)); transform.position += transform.forward * speed * Time.deltaTime; }