- Home /
Trying to reset lvl on collsion
Trying to make a 2d game a reset the level on collision with a boxcollider2d here's what i got ;
void OnCollisionEnter2D(BoxCollider2D col)
{
;
if (col.gameObject.tag == "Player")
{
Scene level = SceneManager.GetActiveScene();
SceneManager.LoadScene(level.name);
}
}
I don't quite understand what you are asking for . Could you try a bit more clearer. I will help you
Are you sure the collision is detected? Put a Debug.Log outside of the condition to check. If not, please, follow the tutorials and make sure all the conditions for collision detection are met (2 non-trigger colliders, 1 non-kinematic Rigidbody on GameObject)
Wow so passive aggressive and I did and it not work so that why I'm here!
Wow so passive aggressive
I am sorry if you have been offended, that was not my intention.
I did and it not work
What have you done? Put a Debug.Log outside of the condition? Can you describe your Physics setup? Objects involved? Their respective components?
Answer by Ginxx009 · May 31, 2018 at 05:51 AM
If you want to reset the level . You could do this in a simple way
Application.LoadLevel(Application.loadedLevel)
This is the proper way of restarting your level.
Your answer
Follow this Question
Related Questions
How would i calculate the size of a 2D area closed off by multiple colliders? 1 Answer
i have a problem with reloading with Time.time 2d game c# Unity 2020.2 1 Answer
2D player keeps getting dragged to the left for some reason. 0 Answers
What is the purpose of this function? "protected virtual void Init() { }" 1 Answer
How to move Instantiated 2D objects by 0.5 using arrows(or mouse) 1 Answer