hi every one! I am doing a 2d car game in which player (car) should enter the end line. everything is alright but only the end flag. When car collide the 2d flag, Win UI canvas should be set active. I am new to unity and programming field. Bros and Sis pls help! First I try to open new scene. the script that had been attached to End Flag first. the car is not collide with flag, not working fine. I add 2d box collider and triggered it, no use! then I added the script to my car, that also not working. Here is my script : using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class FinishScript : MonoBehaviour { void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.name == "EndFlag") { SceneManager.LoadScene("Finish"); } } }
Then I changed my idea now I need to do is to open a canvas and set it active pls help! I don’t know the script for this and where to add the script (which game object) Here is the funny Script : `using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class WinUI : MonoBehaviour { public static bool YouWin = false;
public GameObject WinMenuUI;
void Start()
{
Time.timeScale = 1f;
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.name == “EndFlag”)
{
if (YouWin)
{
Resume();
}
else
{
Win();
}
}
}
public void Resume()
{
WinMenuUI.SetActive(false);
Time.timeScale = 1f;
YouWin = false;
}
void Win()
{
WinMenuUI.SetActive(true);
Time.timeScale = 1f;
YouWin = true;
}
public void LoadMenu()
{
SceneManager.LoadScene(“Main Menu”);
Time.timeScale = 1f;
}
public void Restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
Time.timeScale = 1f;
}
}` some words are just for fun PLS PLS HELP!! THANKS IN ADVANCE!