I’m currently working on a starfox-style game. The idea is for the player to play through all levels without going back to a menu. Thus I want to swap out the skybox and lighting at certain points of the game. I’ve managed to quite simply swap the skybox thus far, but what I really want is to have a smooth fading effect.
My code thus far looks like:
using UnityEngine;
using System.Collections;
public class NewLevel : MonoBehaviour {
public Material material1;
public Material material2;
public float duration = 2.0F;
private bool newlevel= false;
void Start() {
newlevel = false;
}
void OnTriggerEnter(Collider other)
{
newlevel = true;
}
void Update() {
if (newlevel = false) {
RenderSettings.skybox= material1;
}
if (newlevel = true) {
float lerp = Mathf.PingPong (Time.time, duration) / duration;
RenderSettings.skybox.Lerp (material1, material2, lerp);
Debug.Log ("Skybox should be changing right about now");
}
}
}
The thing is that thus far it does nothing. In fact, as soon as I start the game, the debug message pops up, despite nothing actually colliding with the box. Any suggestions?