My rocket is spawning repeatedly

I feel like I’m missing something obvious but my rocket instantly respawns instead of respawning only once

using UnityEngine;
using UnityEngine.SceneManagement;

public class ColliderManager : MonoBehaviour
{

private void OnCollisionEnter(Collision other)
{
    switch (other.gameObject.tag) 
    {
        case "Friendly":
            Debug.Log("this is friendly");
            break;

        case "Obstacle":
            Debug.Log("You hit the Obstacle");
            break;

        case "Finish":
            Debug.Log("YOU WON");
            break;

        case "Fuel":
            Debug.Log("You picked up fuel");
            break;
        
        default:
            ReloadLevel();
            break;
    }
}

void ReloadLevel()
{
    int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
    SceneManager.LoadScene(currentSceneIndex);
}

}

Nevermind I realize I forgot to set the tags

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms