- Home /
Dice roll collision sound
hey guys, i'm trying to reproduce the sound effect of a rolling dice, but i can't really figure out how to do that. I tryied with a simple oncollision function on a cube mesh, but the result was far from what I need.
You need to post your code please. So that we can tell you where you are wrong.
doing it with colliders "may" work if you cube has various colliders around it. one collider is not goin to give the effect unless you just fake it!
I have no code to post I'm sorry! so if not using colliders, what should I use? thanks for the answers
Answer by gregzo · Apr 13, 2012 at 10:10 AM
Fake like a true conArtist!
var myDiceRolls:AudioClip[]; //assign a few different roll sounds here, in ascending length(shorter to longer clips, for example)
OnCollisionEnter(collision : Collision)
{
if(audio.isPlaying==false)
{
var soundIndex : int = collision.relativeVelocity.magnitude; //this will round the magnitude. Will need tweaking.
audio.clip=myDiceRolls[soundIndex];
audio.Play();
}
}
Easy answer: Fake it using pre-recorded dice rolls.
$$anonymous$$ore difficult : A mix of "dice hits" and "rolls": trigger the hits if the collision's relative magnitude is great enough, and once you detect more than x hits in a small amount of time, fire the "roll" sounds. Tricky...
This is really the kind of job F$$anonymous$$OD Designer is meant for, alas not compatible with Unity unless you use a plugin (I happen to have commissioned one...).
Your answer
Follow this Question
Related Questions
Falling Objects Sound 1 Answer
Having an array of points(vector2), how do I create a 2d terrain? (new to unity) 2 Answers
Combine common surfaces 1 Answer
Unity3D Playing Two Sounds - OnCollision 1 Answer
Leap motion: how to pickup a custom mesh 0 Answers