Can someone point me in the right direction for getting dice to behave properly when the device is shaken? Thanks, -Mike
Hi, can you clarify what you are trying to do? Are you just wanting the shake to trigger some animation/action or are you wanting to physically simulate real dice? For the simulation you could create an object with some children that each have a box collider , corresponding to the edges of the iphone (all six, although you probably want the screen collider to be a bit higher than the phone). Make your camera a child of this object too. Code (csharp): -Box (GameObject with script) - ColliderRight - ColliderLeft - ColliderTop - ColliderBotoom - ColliderBase - ColliderScreen - Camera -Dice 1 -Dice 2 Then translate (rotate) this object based on the accelerometer input. The accelerometer tells you which way gravity is pulling so should be fairly trivial to turn this into an orientation for your Box game object. As long as your dice are small (and rigidbodies with colliders) they should start falling and bouncing around quite realistically.
Sorry for the unclear goal. You're approach is interesting, originally I was trying to move the dice vs. the "world" it's in. I will try this tomorrow..err...today, but later. Thanks, -Mike
That should be fine too, I figured it might be easier to translate the accelerometer data to "box" rotations.
I agree, I was having trouble getting them to look real and change the side they were facing, which made them quite useless. I'll post my results in the next day or two. -Mike
I'm guessing this won't work Code (csharp): this.gameObject.transform.Rotate(iPhoneInput.acceleration);