P
P
Piffy2020-02-03 15:54:18
2D
Piffy, 2020-02-03 15:54:18

Unity C# - How to make the level reload when a character enters a certain area?

I'm new, working on a mini (super mini) game. So that when the character fell into the abyss or went where it was not necessary, the level would restart. Here is part of the code, but it does not work (I write the code in Xamarin). Help to add!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dieCollider : MonoBehaviour{
void OnCollisionEnter2D (Collider2D col) {
if (col.gameObject.name == "dieCollider")
Application .LoadLevel (Application.loadedLevel);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2020-02-03
@GavriKos

looking for a code in Xamarin

and I see the code for Unity. Which by the way is not in the tags at all.
Also, it's not a code. until it is in the "CODE" tag!
On the question:
1) Has the component been hung on an object?
2) Colliders hang and are set up (rigidbody/triggers)
3) In OnCollision, execution generally occurs when there is a collision (put a log or uncover a debugger)
4) See what the debugger encountered.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question