After carefully scrutinizing my code and comparing to the project changes, I think I must ask, why my code won’t work. The trouble is, after I hit an obstacle and state is set to dead, the LoadNextLevel() method seems to just forget it is it’s turn and never loads. If someone can be so kind and look at it then I’d be eternally grateful.
using UnityEngine; using UnityEngine.SceneManagement; public class rocket : MonoBehaviour { Rigidbody rigidBody; AudioSource rocketRumble; [SerializeField] float rcsThrust = 100f; [SerializeField] float mainThrust = 100f; enum State {alive, dead, ascending}; State state = State.alive; // Use this for initialization void Start () { rigidBody = GetComponent<Rigidbody>(); rocketRumble = GetComponent<AudioSource>(); } // Update is called once per frame void Update () { if (state == State.alive) { Rotate(); Thrust(); } } private void OnCollisionEnter(Collision collision) { if (state != State.alive) { return; } switch (collision.gameObject.tag) { case "Friendly": break; case "finish": state = State.ascending; Invoke("LoadNextScene()",1f); break; default: state = State.dead; Invoke("PlayerDied()", 1f); break; } } private void PlayerDied() { SceneManager.LoadScene(0); } private void LoadNextScene() { SceneManager.LoadScene(1); } private void Rotate() { rigidBody.freezeRotation = true; float rotationThisFrame = rcsThrust * Time.deltaTime; if (Input.GetKey(KeyCode.A)) { transform.Rotate(Vector3.forward * rotationThisFrame); } else if (Input.GetKey(KeyCode.D)) { transform.Rotate(-Vector3.forward * rotationThisFrame); } rigidBody.freezeRotation = false; } private void Thrust() { if (Input.GetKey(KeyCode.Space)) { rigidBody.AddRelativeForce(Vector3.up * mainThrust); if (!rocketRumble.isPlaying) { rocketRumble.Play(); } } else { rocketRumble.Stop(); } }