Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int DetermineDiceFace()
- {
- Vector3 upDir = Vector3.back;
- float x = Vector3.Dot(transform.right, upDir);
- float y = Vector3.Dot(transform.up, upDir);
- float z = Vector3.Dot(transform.forward, upDir);
- float xAbs = Mathf.Abs(x);
- float yAbs = Mathf.Abs(y);
- float zAbs = Mathf.Abs(z);
- if (xAbs > yAbs)
- {
- if (xAbs > zAbs)
- {
- return x > 0 ? 1 : 6;
- }
- else
- {
- return z > 0 ? 2 : 5;
- }
- }
- else if (yAbs > zAbs)
- {
- return y > 0 ? 3 : 4;
- }
- else
- {
- return z > 0 ? 2 : 5;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement