public void DetachTrail() { if (TrailEffect != null) { TrailEffect.transform.parent = null; TrailEffect.enabled = true; ParticleSystem ps = TrailEffect.GetComponent <ParticleSystem>(); if (ps != null) { ps.Stop(); } } }
// Update is called once per frame void FixedUpdate() { if (state == Modes.Exploding) { if (counter.Count(ExplosionTime)) { explosionObject.transform.parent = null; explosionObject.enabled = true; explosionObject.GetComponent <ParticleSystem>().Stop(); GameObject.Destroy(gameObject); } } else { float dist = (transform.position - Planet.transform.position).magnitude; if (state != Modes.Flying && dist > camController.MaxSize) { StartDestruction(); } if (state == Modes.Orbiting) { if (counter.Count(FirePeriod)) { animator.SetTrigger("Fire"); counter.Reset(Random.Range(0, FirePeriod * 0.15f)); } } else if (state == Modes.Appearing) { if (counter.Count(AppearingTime)) { counter.Reset(); state = Modes.Orbiting; GetComponent <Collider2D>().enabled = true; } } } }