Not a programmer, but working on a game where I need to roll dice.
I am trying to figure out a script in C# to roll two sets of dice. One set would include 1-3 6 sided dice, the other would be 1-2 6 sided dice. What I'm trying to figure out is: How do I read which face is up? How do I match the two highest values on each set? How do I match the two second highest values on each set? How do I get a motion of "thrown" dice? How do I add the physics for the dice?
I already have the models and want to tie the script into these vs. a random number generator.
Answer by Jessespike · Aug 10, 2016 at 09:49 PM
Q: How do I get a motion of "thrown" dice? How do I add the physics for the dice?
A: Add a RigidBody to them and use AddForce or AddForceAtPosition to simulate a throw.
Q: How do I match the two highest values on each set?
Q: How do I match the two second highest values on each set?
A: After the drop has finished, calculate the values of the dice by checking which side is facing up. Store the values of a set into an array or list and loop through them, checking which ones are the highest or second highest values.