hello,
i want to calculate the upper face of dice; after googling i got the following code. this code doesnot work perfect, sometime it returns 0 value for upper face.
could someone help me to sort out the issue.
//function to calculate upper side
//currObject is the dice
function CalcSideUp(currObject : GameObject) {
var dotFwd : float = Vector3.Dot(currObject.transform.forward, Vector3.up);
if (dotFwd >= 0.99) return 5;
if (dotFwd <= -0.99) return 2;
var dotRight : float= Vector3.Dot(currObject.transform.right, Vector3.up);
if (dotRight >= 0.99) return 4;
if (dotRight <= -0.99) return 3;
var dotUp : float = Vector3.Dot(currObject.transform.up, Vector3.up);
if (dotUp >= 0.99) return 6;
if (dotUp <= -0.99) return 1;
return 0;
}
Thanks