You’d need six animations for each outcome of the dice. However a way to get past having six animations for each dice would be to have six dice and ONE animation that lands with the same side at the top each time. Each dice would be textured so that the top number would be different. Therefore you could just select a dice, roll it, and it would have the number you want on top. Either that, or have six individual animations you can select.
Generating a random number is not difficult, simply google for either javascript or C# examples of random number generation.
Activating a trigger should be simple enough, and there are plenty of examples.
A run through of your script might look like this:
Trigger activated.
Generate a random number between one and six.
Use that generated number to select dice animation.
Play selected dice animation.
What bit are you having trouble with specifically? Is it finding a working random number generator or creating the animations for the dice for each number?
…Or one animation that always lands in the same position, but put the dice as a child object.
Pick a random number 1-6 to determine what side will face up. Pick a random number 1-4 to decide how the dice will be oriented after landing. Or pick a random number 1-24 to do both at once.
You could also have multiple animations, or combinations of animations, to make the dice roll seem more natural and random. Maybe certain animations curves could be slightly tweaked at runtime. Making the rolls look natural without wasting resources on physics simulations is the most difficult part.
As much as they might appreciate your answer, the thread is almost 12 years old, surely they have moved on by now. Make sure to check that you’re not necro-ing old threads like this.
Since it’s already bumped, I answered a similar question on UnityAnswers some years back. It works with any number of sides, though you have to setup the “sides” manually. Though I’ve linked some scripts which would help with the setup. In essence you can give every side a normal vector and the side which is closest aligned to the world up vector, is the upper side.