Hello! My working level change script currently fades into the next level:
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelChange : MonoBehaviour {
public string loadLevel;
public Color loadToColor = Color.white;
void OnTriggerEnter(Collider other)
{
if (other.CompareTag ("Player"))
{
Initiate.Fade(loadLevel, loadToColor, 0.5f);
}
}
}
However, I would like to randomize the level selection between two levels, so I used an array:
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
public class RandomizedLevelChange : MonoBehaviour {
public string[] loadLevel = new string[2] {"believer", "nonbeliever"};
public Color loadToColor = Color.white;
void OnTriggerEnter(Collider other)
{
if (other.CompareTag ("Player"))
{
Initiate.Fade(loadLevel[Random.Range(0, 2)], loadToColor, 0.5f);
}
}
}
Now, the randomized level selection works, but this somehow breaks the fade script. Any ideas? I’m new to coding so I’m sure I’m missing something straightforward.