3D Unity Course - Reload Scene After Collision PROBLEM

I copied the code from the resources in the description just to be sure if it works too and it still didn’t. So, the course episode showed that if i bump my rocket into a object it will collide and therefore reset the level… I did everything like in the video, there are also no problems in the console and copied the code from the tutor… I am so confused… The only thing that is different from the course is the name of the script called " Handler Colision instead of ColissionHandler which I also doubled checked in the code…I also have my Scene in the project Build and even restarted my pc… my level won’t restart… help…

Can we see the collision handler code?

Ofcrouse mate! Thanks for helping me out, here is the code:

using System;

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.SceneManagement;

public class HandlerColision : MonoBehaviour

{

   [SerializeField] float loadDelay = 1f;

   

    void OnTriggerEnter(Collider other)

    {

        StartCrashSequence();    

    }

    void StartCrashSequence()

    {

        GetComponent<RocketControl>().enabled = false;

        Invoke("ReloadLevel", loadDelay);

    }

    void ReloadLevel()

    {

        int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;

        SceneManager.LoadScene(currentSceneIndex);

    }

}

Hi Krokokeks,

Collisions happen between two Collider components. First of all, add a Debug.Log to your OnTriggerEnter method to see if the code block gets executed.

If it does not get executed, check if the other collider has “Is Trigger” enabled in its Collider component. If the other collider is not a trigger, OnTriggerEnter will never get called.

Oh my god how can I be so stupid… I apologize… I forgot to tick the Is Trigger box… thank you so much i was so lost

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

Privacy & Terms