Hi, I have a house asset in my game and at the front door I have a cube acting as a trigger to transition from my ‘outdoor’ audio snapshot to my ‘indoor’ audiosnap shot, and vice-versa. As a sound designer I am a complete newbie to scripting and have been trying to figure out how to use the - public function TransitionTo(timeToReach: float): void; - to no success.
Does anyone have any advice on how I can script this?
This is what I have so far from watching youtube videos and trying to piece together different scripts
using System.Collections;
using UnityEngine;
using UnityEngine.Audio;
public class snapshotchanger : MonoBehaviour {
private bool isTriggered;
public void TransitionTo(float timeToReach);
public AudioMixerSnapshot IndoorsSnapshot;
public AudioMixerSnapshot OutdoorsSnapshot;
public float transitionTime = 2.0f;
public void OntriggerEnter(Collider other)
if (!isTriggered)
TransitionTo(1.0f);
}
}
Managed to sort it. I am now trying to make it that if the player leaves the house then it will switch back to the outdoor snapshot. I have been trying to make an if statement but I can not add variables to the script for some reason.
using System.Collections;
using UnityEngine;
using UnityEngine.Audio;
public class snapshotchanger : MonoBehaviour {
public AudioMixerSnapshot Indoors;
public AudioMixerSnapshot Outdoors;
void Start () {
}
void Update () {
}
public void OnTriggerEnter(Collider collision){
Indoors.TransitionTo (2.0f);
}
}
use OnTriggerExit(Collider c) to transition to outdoors. variables are added after “using” statments and before the first void, or between brackets