Dice Testing

Hey everyone.

I’m making a dice game, not too far away from yahtzee or something where you roll the dice and save some on the side and roll the rest.

Basically right now I want to roll a dice and know what it landed on. It’s like stupidly simple but i don’t really know how I can go about and do it. I might check the rotation? I tried a few rolls and check the transform.rotation to try and check if it’s consistant, but it’s not!

Also it gives me a quaternion, where I really would like to see a vector.

Here’s the masterful coding I did, it gets instanciated with the dice:

function Update () {

		if (rigidbody.velocity == Vector3.zero  transform.position.y < 3 ){
			
			Debug.Log(transform.rotation);
//apply a tag of what the dice is depending on the face landed up, probably with a simple switch thing.
			Destroy(GetComponent(DiceID));
		}
		

}

any tips? Be gentle, i’m a total noob.

Assuming your dice is a cube mesh and that cube mesh doesn’t share vertices you might consider checking which faces have their normal facing up. That would at least get you the side - you’d then need another step to determine the “value” on that side of the dice.

You may also be able to check which face is touching the ground using either collision or OnTriggerEvents(). On top of this you could also assign a value to each specific Vector3 rotation or have a raycaster extruding from each face to the table and check which one is verticle.