Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Mz3D · Sep 03, 2012 at 10:12 AM · mobileshakeshakingdice

Dice shaking (mobile)

Hello everyone!

"i just want to add a force to an object in a physic 3d world according to accelerometer value changes. This is the main problem."

background:

I would like to create a dice shaking game. The user shakes the mobile device and the 3d dices on the screen roll around. That's all. I have no idea for now about how to realize this, surely i'll have to use physics and forces and make them related to accelerometer values. Anyone can suggest me some code to start from or something i can read? It seems there's no much documentation about this particular case on the web. I've only found this question http://answers.unity3d.com/questions/53751/shake-object-on-iphone.html?sort=oldest but the solution doesn't explain much.

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlucardJay · Sep 03, 2012 at 10:30 AM 1
Share

You need to break this down, then resolve all the smaller problems.

1/ create a dice.

2/ make the dice roll on command.

3/ work out how to deter$$anonymous$$e when the dice has stopped rolling, and deter$$anonymous$$e the face that is facing up.

4/ use the accelerometer to trigger the dice-roll.

some reading to get you started : https://www.google.com/search?btnG=1&pws=0&q=unity+dice+roll

avatar image Mz3D · Sep 03, 2012 at 10:33 AM 0
Share

i just want to add a force to an object in a physic 3d world according to accelerometer value changes. This is the main problem.

avatar image 3agle · Sep 03, 2012 at 10:46 AM 0
Share

Not sure why that should be a problem, Input.acceleration gives a Vector3 value, and Rigidbody.AddForce takes a Vector3 value. All you have to do is make sure the axes are lined up and have the right size value.

some links: http://docs.unity3d.com/Documentation/ScriptReference/Input-acceleration.html

http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html

avatar image AlucardJay · Sep 03, 2012 at 10:50 AM 1
Share

Have a look at the Unity Examples for learning to use and implement the accelerometer : http://unity3d.com/support/resources/example-projects/iphone-examples

Download and look at Roll-A-Ball =]

also http://answers.unity3d.com/questions/63433/moving-an-object-with-accelerometer-using-unity-ip.html

avatar image AlucardJay · Sep 04, 2012 at 10:14 AM 0
Share

How did you go? Another link has just popped up in the answers : http://vimeo.com/48791493

I think your question is more about detecting the magnitude of the change in accelerometer value over time. So in the first moment, you read the outputs of accelerometer, then in the next moment you read again and compare the change in value. If that change is greater than a certain amount, you know how much the phone has moved within a certain timeframe. If that value is greater than some small number, then shake the dice by the amount of change in the accelerometer. I havn't played with accelerometers myself yet, but your question has made me curious and I shall do some experimenting of my own. Don't give up, and keep searching for videos that may help.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Anusha · Sep 04, 2012 at 12:24 PM

 vector3 forward = new Vector3(Input.acceleration.x,Input.acceleration.y , Input.acceleration.z);
 rigidbody.AddForce(forward,ForceMode.Acceleration);
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Make object shaking when is damaged 1 Answer

Camera Shaking Problem 0 Answers

how can my gameobject stop shaking? 1 Answer

Shaking angles using gyro attitude 1 Answer

Shaking screen using the gyroscope attitude 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges