Killzone Prefab not working?
Hi I'm trying to use the Killzone prefab to restart my scene when the player falls off a platform. My character goes through the collider and nothing happens? Does it need any additional code? also my character is just the default robotboy prefab.
this is the restarter script it uses
using System; using UnityEngine; using UnityEngine.SceneManagement;
namespace UnityStandardAssets._2D { public class Restarter : MonoBehaviour { private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { SceneManager.LoadScene(SceneManager.GetSceneAt(0).path); } } } }
the killzone prefab is part of the 2d standard assets
try setting sleep mode to "Never Sleep" on rigidbody of $$anonymous$$illzone
$$anonymous$$ake sure the player is tagged player, has a 2D Collider and a 2d rigidbody attached.
Answer by I82Much · Sep 30, 2016 at 09:39 AM
Check to see that your current level has been added to the build settings. If it hasn't, you'll see an error like
Scene 'Assets/Scenes/Level1.unity' (-1) couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded. To add a scene to the build settings use the menu File->Build Settings... UnityEngine.SceneManagement.SceneManager:LoadScene(String) UnityStandardAssets._2D.Restarter:OnTriggerEnter2D(Collider2D) (at Assets/Standard Assets/2D/Scripts/Restarter.cs:14)