- Home /
Making a singing bowl sing in VR, responding to incoming angle
I have the model, the looping audio tracks, and velocity-responsive audio script, but no good solution.
Ideally, I would like a VR controller to be able to tap the side of a singing bowl to play one sound, and trace along the side for the looping resonant sound (like tracing your finger along the rim of a wine glass). The velocity of the hit would change the volume, not the track.
Bonus question! Then there's the problem of the concave collider. I can make a sphere collider for now, but if I wanted to be thorough and place a hundred tiny box colliders along the sides so it can't sound in the center, how would I keep a continuous sound, with the script in each one? Or should I give up on that part?
Current script below. Senses velocity of impact and switches the audio clip with a higher speed. I need to switch 'relative velocity' to 'angle of impact < 45' angle.'
public class sfxBowlHit2 : MonoBehaviour {
public AudioClip hitDirect;
public AudioClip hitSlide;
private AudioSource source;
private float velToVol = .25F; // Louder volume when hit with higher velocity
private float velocityClipSplit = 10F; // Switch audio clip once reaching this threshold
void Awake () {
source = GetComponent<AudioSource>();
}
void OnColliderEnter (Collision coll) //coll is a standard Unity variable
{
float hitVol = coll.relativeVelocity.magnitude * velToVol; // Louder volume when hit with higher velocity
if (coll.relativeVelocity.magnitude < velocityClipSplit) // Need to adapt this from velocity to angle of impact
source.PlayOneShot(hitDirect,hitVol);
else
source.PlayOneShot(hitSlide,hitVol);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612133515im_/https://answers.unity.com/themes/thub/images/avi.jpg)