IEnumerator Death() { GameObject temp = gameObject; spawning.SetPosition(ref temp, false); Start(); yield return(null); }
// Update is called once per frame public IEnumerator Seek() { swarmAnim.PlayQueued("Walk"); StartCoroutine(RandomDelaySoundLoop(swarmSoundRandomValMin, swarmSoundRandomValMax)); while (isActive) { Move(swarmSpeed); if (Vector3.Distance(transform.position, target.position) < SWARM_ATTACK_RANGE) { Attack(1); } yield return(new WaitForFixedUpdate()); } swarmAnim.Stop(); swarmAnim.PlayQueued("Splay"); rigidbody.AddTorque(50f, 0, 0, ForceMode.VelocityChange); yield return(new WaitForSeconds(timeBeforeRespawn)); GameObject temp = gameObject; swarmSpawner.SetPosition(ref temp, true); }