Rocket Prefab Explosion

void OnCollisionEnter(Collision collision)
{
if (state != State.Alive) { return; } // ignore collisions when dead

    switch (collision.gameObject.tag)
    {
        case "Friendly":
            // do nothing
            break;
        case "Finish":
            StartSucessSequence();
            break;
        default:
            StartDeathSequence();
            break;
    }
}

private void StartSucessSequence()
{
    state = State.Transcending;
    audioSource.Stop();
    audioSource.PlayOneShot(sucess);
    sucessParticles.Play();
    Invoke("LoadNextLevel", 1f); // parameterise time
}

private void StartDeathSequence()
{
    state = State.Dying;
    audioSource.Stop();
    audioSource.PlayOneShot(death);
    deathParticles.Play();
    Invoke("LoadFirstLevel", 1f); // parameterise time
}
2 Likes

I love it great job!

Boom! love it

Privacy & Terms