// Start is called before the first frame update void Start() { if (lightningAnimator == null) { lightningAnimator = Instantiate(chainLightning, targets[0].transform.position, Quaternion.identity).GetComponent <LightningAnimator>(); } lightningAnimator.SetTargets(targets); }
protected override void OnTriggerEnter(Collider other) { base.OnTriggerEnter(other); foreach (var enemy in hitTargets) { StartCoroutine(enemy.GetComponent <EnemyBase>().AltFireEnemySlowed(_slowModifier, _slowDuration)); } LightningAnimator animator = Instantiate(_chainLightning, transform.position, transform.rotation).GetComponent <LightningAnimator>(); animator.SetTargets(hitTargets); StartCoroutine(DestroyLightning(animator)); }
IEnumerator DestroyLightning(LightningAnimator animator) { yield return(new WaitForSeconds(_lightningDuration)); animator.DestroyLightning(); }