So I made this script and basically what It’s meant to do is make one portal take you to one scene and the other to the other scene. It’s also meant to make things frustrating by randomising which portal takes you to which scene every time you try the level or whatever.
My script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class portalControls : MonoBehaviour
{
public string newGameLevel1;
public string newGameLevel2;
private int coin;
void start()
{
coin = Random.Range(1, 3);
}
void OnTriggerEnter(Collider other)
{
Debug.Log (coin);
if (other.gameObject.CompareTag ( "Portal1"))
{
if (coin == 1)
{
SceneManager.LoadScene (newGameLevel1);
}
else if (coin == 2)
{
SceneManager.LoadScene (newGameLevel2);
}
}
if (other.gameObject.CompareTag ( "Portal2"))
{
if (coin == 1)
{
SceneManager.LoadScene (newGameLevel2);
}
else if (coin == 2)
{
SceneManager.LoadScene (newGameLevel1);
}
}
}
}
can someone help me out with this? thanks!
sorry if i didnt make much sense im tired asf