void OnTriggerStay(Collider col) { Vector3 colPos = col.gameObject.transform.position; Debug.Log("Collision with " + col.gameObject.name); if (colPos.y < 1.2) { myOsc.PlaySound(0); } else if (colPos.y < 1.4) { myOsc.PlaySound(1); } else if (colPos.y < 1.6) { myOsc.PlaySound(2); } else if (colPos.y < 1.8) { myOsc.PlaySound(3); } else if (colPos.y < 2) { myOsc.PlaySound(4); } mySynthControl.SetVolume(Mathf.Lerp(-80f, 0f, colPos.z)); mySynthControl.SetCutoff(Mathf.Lerp(100f, 15000f, colPos.x)); PlayParticles(); }
void DetermineNote(Collider col, Oscillator osc) { Vector3 colPos = col.gameObject.transform.position; float distFromBottom = colPos.y - bottom; int localOctave = (int)Mathf.Round(distFromBottom / noteSpacing) / (osc.frequencies.Length); int note = (int)(Mathf.Round(distFromBottom / noteSpacing) % (osc.frequencies.Length)); //print("octave: " + localOctave + " note: " + note); if (note >= 0) { osc.PlaySound(note, localOctave); } }