- Home /
How to make any dice have a given face(int) face up?
Basically I have 4,6,8,10,20 sided dices, they work fine for rolling and everything but now I want to implement a feature where if you click a dice with value of 2, it'll rotate to have 5/6 facing up...pretty sure I need math but am really bad with it...
huh ?
I don't follow your question, but if what you're trying to do is orient the dice so that a particular face is pointing up, i'd suggest 1) attaching a transform (game object) to each face, with the positive Z direction facing away from the die. 2) choose which face you want to orient up. 3) get that face's transform's Z direction. 4) use Quaternion.FromRotation() to get the rotation need to rotate that Z vector to world Up. 5) apply that rotation gradually with Quaternion.Slerp() to get a nice animation.
Answer by Breyyne · Jan 07 at 07:46 PM
You could check on click if it is '2' then trigger an animation that 'flips' it to the desired side up.
Well I'd need an initial frame in the animation that would be different if say I rolled a 2 and need it to flip to 6, if the initial frame is at 1 it'll look weird. In the end got Dotween free and use Dotate the the needed rotation.
Your answer
Follow this Question
Related Questions
Follow rotation on Y axis ONLY clockwise/counterclockwise. 1 Answer
Directional booster 1 Answer
Smooth rotation to child object 1 Answer
Rotate object based on hit normal + matching camera direction 0 Answers
Trouble with Camera Rotation Math 2 Answers