private void Update() { if (target.Equals(null)) { Destroy(this.gameObject); } else { if (Vector3.Distance(transform.position, target.transform.position) > 1) { float step = speed * Time.deltaTime; transform.position = Vector3.MoveTowards(transform.position, target.transform.position, step); } else { target.TakeDamage(dmg); Destroy(this.gameObject); } } }