Key press detection
void Update ()
{
if (state == State.Alive)
{
RespondToThrustInput();
RespondToRotateInput();
if (Input.GetKeyDown(KeyCode.L))
{
StartSuccessSequence();
}
if (Input.GetKeyDown(KeyCode.C))
{
collisionsEnabled = !collisionsEnabled;
}
}
}
Collisions
Added a boolean for enable/disable switching of collisons:
bool collisionsEnabled = true;
Altered the StartDeathSequence to return early if the collision detect flag was off:
private void StartDeathSequence()
{
if (!collisionsEnabled) { return; }
state = State.Dying;
audioSource.Stop();
audioSource.PlayOneShot(death);
deathParticles.Play();
Invoke("LoadFirstLevel", levelLoadDelay);
}
Changing levels
I first did this by calling LoadNextLevel() from within the Update method, I went back and changed to calling StartSuccessSequence(), justification for doing was that it gave audible feedback and the state was being set so it might protect me in the future.