hi all,
i have 7x7 grid surface.each grid is of 1x1; i have placed cube over the grid say 5 cube(dice). now the scene is i have the position of the placed cube(dice). and i want to adderss each cube without touching it.for detecting upper surface of cube(dice).
how could i do this?
Thanks
I don’t exactly understand your question.
One thing I think you might be asking is how can you detect what is the top face of your dice.
I’ve been working on a game where I will have dice rolling, and I need to determine what face is the top face.
In order to do that, I made a script for my dice, which goes on each of them. This script is responsible for telling external entities which subscribe to it(via events) that it has finished rolling as well as what side of the dice is facing up.
In order for my dice to figure out which of their sides is facing up, I do a collider.raycast on the dice, starting above it in the Y and going downward. When it hits the dice, I store the RaycastHit information in a variable which tells me which triangleIndex was hit.
Since for now I am only using the most simplistic of 6 sided dice with 2 triangles for each face, there is a possible number of 2 triangles in the triangleIndex that correspond to my dice face. I use a lookup table(a simple generic Dictionary<> in C#) where I feed in the triangleIndex number and it returns the number of the dice.
Since I had no way of determining which triangleIndex corresponded to which face, I had to do debug which told me which triangleIndex it was and I compared that visually to the dice as I was looking at… jotting down the information until I gathered it all, and then added that information into my dictionary.
So all in all, I had the dice themselves determining which face they had pointing up, and broadcasting that information via evens. The information was there, other scripts only had to subscribe to it to get that information if they wanted it.
seems to me like you could make your model with a bone in the center and a bone touching the middle of ea side of the dice and simply retun the bone posistions and the one that has the highest y value would be the face that is shown
Hmm stop me if I am wrong but…
Wouldn’t it be easier to determine the face by looking at what “transform.up” is pointing to?
If you place the 1 pip at (0, -1, 0) and the 2 pips at (1, 0, 0) it’s rather easy to determine the face that is point up.
(0, -1, 0) = 1
(1, 0, 0) = 2
(0, 0, 1) = 3
(0, 0, -1) = 4
(-1, 0, 0) = 5
(0, 1, 0) = 6
So you do your raycast, get hit.transform.up, and just compare with this table to know the value.
And this would work for all die, with any numbers of face, as long as you know the value of “transform.up”
Also, your game makes me think of Devil’s Dice
Edit : I just saw that you want to know the face without touching them. It’s not harder, looking at transform.up can be done without touching…
Hi, i’d ilke to do the same to iphone. A dice game.
Could you put an example with your final solution, please?
:-S
Thanks.