I’m building a game where, at the end of each level, a results screen is shown, with the game in the background. Once the screen is accessed (you fly into a trigger box), I want a victory tune to play. To do this, I have written the code to be as such:
using UnityEngine;
using System.Collections;
public class NewLevel : MonoBehaviour {
public Material otherSkybox;
private bool newlevel= false;
public GameObject camera;
public AudioClip victory;
void Start() {
newlevel = false;
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player"){
newlevel = true;
}
if (newlevel== true){
RenderSettings.skybox = otherSkybox;
camera.audio.Play(victory);
transform.localPosition = new Vector3(0, 0, 0);
print(transform.localPosition.y);
}
}
}
The problem I have is however that I get the following compile error:
The best overload match for “unityengine.audiosource.play(ulong)” has some invalid arguments. And that’s strange, since I’ve basicaly copied the example in the unity documentation pages.