Exemplo n.º 1
0
    /// <summary>
    /// Destroys the player object and plays the explosion animation.
    /// </summary>
    public void DestroyPlayer()
    {
        if (explosionPrefab != null)
        {
            var explosion = Instantiate(explosionPrefab, _player.transform.position, Quaternion.identity);
            explosion.transform.SetParent(_rootFolder.transform);

            SelfDestruction sd = explosion.AddComponent <SelfDestruction>();
            sd.SetDelay(1.0f);  // Cartoon explosion is kinda weird - use hardcoded length!
            //sd.SetDelay(explosionPrefab.GetComponent<ParticleSystem>().main.duration - 0.1f);
        }
        else
        {
            Debug.Log("No explosion Prefab found!");
        }

        Destroy(_player);
    }