# Problem Description

During our development of Settlers of Catan, we met a subfunction level problem of synchronizing a dice and read the dice result based on the face exposing up.

For example, given two dices in the following positions. You need to detect the facial values of the dices.

The number is printed in console.

# Some Solutions

There are generally 3 ways of tackling down the dicing problem as I brainstormed and researched:

1. Make each dot a prefab and detect the collision between the dot and surface
1. Use Raycast from top to the dice to detect which surface is hitting up
1. Psedo-Rotation: generate a number first, then have an animation effect of dice rolling. Eventually displays the face that has the same number value as the number generated.

# Easy Approach

The above methods seem to be more real-world focused as if the dice is really there.

However, in unity, each prefab has meta-values such as trasnformation and colliders. After some time of thinking, I came up with a quick solution to the problem, which is to use the rotation of the dice to detect its value.

1. In Unity, the dice without any material is actually a cube

2. We assign a referencial value to the rotation its self. For example, a vector of (0,0,0) will be 4 facing up, (-90, 0, 0) will be 1 facing up.

3. Get Numbers

4. Test it, roll the dice:

1. Print Results to Console

# Synchronization over the Network

At the very end, we need to synchronize the dice move moment across the network with Photon.