Question by
CraftyMaelyss · Aug 20, 2017 at 01:59 AM ·
audiotransitionfadeout
How do I make the audio fade out during a scene transition?
Hi guys!
I'm working on my game and currently with the splashscreen, it transitions into the main menu nicely but my problem at the moment is getting the audio from the splashscreen to fade out during this transition.
It just cuts off and I would rather prefer it to fade out just as the transition does that.
This is my script for the splashscreen that I learned from an online tutorial (on youtube I think) and I would love some advice on how to make the audio fade out when this transition occurs :)
using UnityEngine;
using UnityEngine.Events; //
using System.Collections;
public class Splash : MonoBehaviour {
public int level = 1;
public float setTime = 3.0f;
public float dimTime = 2.0f;
public UnityEvent dimEvent; //
bool isDimming = false; //
public float zoomSpeed = 0.2f;
Camera c;
float timer;
// Use this for initialization
void Start () {
c = GetComponent<Camera>();
timer = 0.0f;
}
// Update is called once per frame
void Update () {
timer += Time.deltaTime;
c.fieldOfView -= zoomSpeed;
if (timer > dimTime && timer < setTime && !isDimming) { //
dimEvent.Invoke (); //
isDimming = true; //
} else if (timer > setTime) {
Application.LoadLevel(level);
}
}
}
Cheers in advance! :D
Comment
Your answer