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
1
Question by B3NN · Jul 13, 2010 at 05:34 PM · iphoneballaccelerometerroll

iPhone ball roll problem

I'm using the Roll-A-Ball script to have a ball roll around a small area and I am having two problems:

1) The ball is rolling around in a box made of flattened cubes. All but the bottom has mesh render removed so they can't be seen. Is there any reason why, when the tilt angle is too great, the ball gains enough momentum to launch out of this box?

2) I want to change the existing script so that when tilted, the ball has a set speed. I need the player to be able to switch directions quickly and this seems impossible as the physics (or accelerometer?) are causing the ball to just slow down and then eventually speed up again when tilt direction is changed.

I think if I could fix problem 1) then I could just increase force enough so that changing direction wouldn't take so long...

Here is the code example:

function Start() { iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape; }

function FixedUpdate () {

 var dir : Vector3 = Vector3.zero;
 dir.x = -iPhoneInput.acceleration.y;
 dir.z = iPhoneInput.acceleration.x;
 if (dir.sqrMagnitude > 1)
      dir.Normalize();
 rigidbody.AddForce(dir * force);   

}

This is looking all funny on my screen, I think I've pressed something wrong trying to copy the code in..

Any help would be greatly appreciated ^_^

Comment
Add comment · Show 1
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 MikezNesh · Jul 13, 2010 at 06:08 PM 0
Share

If you don't want the ball to bounce at all you could set the y axis to zero in the update function.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by B3NN · Jul 21, 2010 at 12:37 AM

Turns out the that the walls used to enclose the ball were not thick enough to contain it.. Just a matter of increasing the thickness. :) This way, I don't have to restrict the ball to just the Y axis and don't need to slow down the fixedTimeStep.

This also allowed me to increase the balls movement speed enough to have the effect I wanted! Was a minor headache, but it's done now :) Thanks for the help above, also :)

Comment
Add comment · Show 1 · 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
avatar image cregox · Jan 28, 2011 at 10:24 PM 0
Share

As for making wall thick, you might want this ins$$anonymous$$d: http://www.unifycommunity.com/wiki/index.php?title=DontGoThroughThings

avatar image
1

Answer by Daniel 6 · Jul 13, 2010 at 06:55 PM

To prevent object's from going through each other, you could just decrease the fixedTimeStep in the physics settings (Edit->ProjectSettings->Physics).

Comment
Add comment · Show 1 · 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
avatar image B3NN · Jul 21, 2010 at 12:33 AM 0
Share

I did try that, however slowing down the fixedTimeStep just slowed down the entire game.. i really wanted the ball to move quickly.

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

No one has followed this question yet.

Related Questions

iphone roll a ball game 2 Answers

Device Orientation Issue 1 Answer

moving an object with accelerometer using unity iphone. 3 Answers

iPhone touch raycasting 1 Answer

External IMU data to control iOS game via BLE 0 Answers


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