How to have a Next Level and Game Over pop up in scene please help!
Hey everyone. I am kind of stuck and was wondering if anyone can help me on this or point me in the right direction. I have a game in which it is level based. Each level I have is a different scene. Is it possible to create a pop up within a scene for next level and game over? Like flow free when you complete the level this comes up:
I do not want to create separate game over and next level scenes. Is something like this possible? And if so, would this be applied to every scene? Or can I make it within one scene and have a script to apply it to every scene? ANY help with this or pointing me in the right direction would be GREATLY appreciated. Thank you!
Answer by $$anonymous$$ · Apr 03, 2016 at 08:18 AM
Well you can play with UI.You create a panel and you can deactivate it,then when you end your level you can enable it via script something like this
Look this
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
public Text countText;
public Text winText;
private Rigidbody rb;
private int count;
public AudioSource audio1;
public GameObject EndPanel;//This gameobject is the panel
void Start ()
{
rb = GetComponent<Rigidbody>();
count = 0;
SetCountText ();
winText.text = "";
EndPanel.SetActive (false);//This keep the panel inactive
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ( "Pick Up"))
{
audio1.Play();
other.gameObject.SetActive (false);
count = count + 1;
SetCountText ();
}
}
void SetCountText ()
{
countText.text = "Count: " + count.ToString ();
if (count >= 12)
{
winText.text = "You Win!";
EndPanel.SetActive (true);//You win the game so the panl is active
}
}
} If you want subscrube to my channel I 'm making simple tutorial https://www.youtube.com/channel/UCCV5S5GAp-sXr4EB-a1TYUA
Your answer
Follow this Question
Related Questions
How to passing levels automatically in games? 0 Answers
How to Manage Objects Common for Multiple Levels? 2 Answers
2+ level Popup on InspectorGUI 1 Answer
Cannot access LevelChanger to change level from the pan/delay coroutine in CameraPanForIntro 0 Answers
I'm trying to make my timer stop and display on the level complete scene 0 Answers