MicControl Script

Get MicControl from the Unity Assest Store

Use this script with your particle generator in Unity3d:


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//change light intensity based on loudness
public class ParticleCount_Loudness : MonoBehaviour {

//create a slot to place our controller in which we want to call from. Instead of GameObject, one could also use MicControlC as a type.
public GameObject controller;
//next we need a float for easy access to our loudness value. (Alternatively, you can also call the loudness value directly).
float getLoudness=0.0f;

//create an extra value to extra amplify our input. This way we can control amplification per object.
public float amp=1.0f;


void Update () {
//update our float every frame with the new input value. Use this value in your code.
getLoudness = controller.GetComponent ().loudness;

if (getLoudness < 2)
{
gameObject.GetComponent().startSize = 0f;
gameObject.GetComponent().startLifetime = 0f;
}
else
{
gameObject.GetComponent().startSize = getLoudness * amp;
gameObject.GetComponent().startLifetime = 16f;
// gameObject.GetComponent().startLifetime = getLoudness * amp * 10f;
}

}

//this value is only meant for the UI slider, you can ignore it.
public void sensitivity(float sense){
amp = sense;
}


}