- Home /
How do I control a box of objects (marbles or dice) with the accelerometer/gyro?
This is for a mobile app. The UI I'm trying to model is a box of dice. Looking into the screen looks down into the box and the app should function as if the screen were a piece of glass over a box you shake.
I'm using Input.gyro.attitude to get the current orientation and use the difference between that and the initial attitude as the current orientation of the box.
Now I'm trying to add forces based on the accelerometer data so you can shake the box instead of just rotating it. I'd like to just add the current acceleration (Input.gyro.userAcceleration) to the box model and have that move and push the dice like a real box would.
I've tried applying the acceleration directly to the dice but flicking the device around pretty much applies a force and then applies the opposite force as I bring the device back to a neutral position.
I don't need code. I just need an algorithim to make sure the right forces are applied to the right objects in the box when the sides of the box should push on the dice.