Need help with my code. It is when the object collides with another object it open another scene.
using UnityEngine;
using System.Collections;
public class SceneResart : MonoBehaviour {
// Use this for initialization
void Start () {
}
function OnTriggerEnter(other:Collider){
if (other == Ball){
Application.LoadLevel(Application.MainScene);
}
}
}
It looks like you’re combining information from JS tutorials with C# tutorials. Make sure you’re using one language, and for best results, make it C#!
// Use this for initialization
void Start ()
{
}
void OnTriggerEnter(Collider other)
{
if (other.GetType() == typeof(Ball))
{
Application.LoadLevel(Application.MainScene);
}
}
using UnityEngine;
using System.Collections;
// I'm sure you meant SceneRestart for the class name
public class SceneResart : MonoBehaviour
{
void OnTriggerEnter(Collider other)
{
// Compare the other by name, if it's the ball, reload/restart current scene
if( other.name == "Ball" )
{
Application.LoadLevel(Application.levelLoaded); // Application.levelLoaded returns an int, basically the scene your in
}
}
}