I currently have some scripts I’m not sure why I’m getting errors Im trying to have a track play after a player collides with an object then after some time have the track fade out currently these are my two scripts and the errors I’m getting
Error List:
Assets\musiccollider.cs(16,54): error CS1003: Syntax error, ‘,’ expected
Assets\musiccollider.cs(16,69): error CS1003: Syntax error, ‘,’ expected
Assets\musiccollider.cs(16,77): error CS1525: Invalid expression term ‘float’
Assets\musiccollider.cs(16,83): error CS1003: Syntax error, ‘,’ expected
Assets\musiccollider.cs(16,93): error CS1525: Invalid expression term ‘float’
Assets\musiccollider.cs(16,99): error CS1003: Syntax error, ‘,’ expected
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class musiccollider : MonoBehaviour
{
[SerializeField]
private AudioSource audio;
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
audio.Play();
StartCoroutine(FadeMixerGroup.StartFade(AudioMixer Master, String Volume, float duration, float targetVolume));
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Audio;
using UnityEngine;
public class FadeMixerGroup : MonoBehaviour {
public static IEnumerator StartFade(AudioMixer Master, string Volume, float duration, float targetVolume)
{
float currentTime = 0;
float currentVol;
Master.GetFloat(Volume, out currentVol);
currentVol = Mathf.Pow(10, currentVol / 20);
float targetValue = Mathf.Clamp(targetVolume, 0.0001f, 1);
while (currentTime < duration)
{
currentTime += Time.deltaTime;
float newVol = Mathf.Lerp(currentVol, targetValue, currentTime / duration);
Master.SetFloat(Volume, Mathf.Log10(newVol) * 20);
yield return new WaitForSecounds(3f);
}
yield break;
}
}