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 easilyBaffled · Aug 25, 2012 at 05:16 PM · rotategravityconstantforce

Creating false gravity for a ball

I have a ball moving through a tube filled with gravity defying twists and turns. I have an empty object sitting at the center of the ball. Every Update I `rigidbody.constantForce.relativeForce = child.transform * -10;` where child is the inner empty object applying this force to the ball to replicate gravity. The next step is to apply turning so the ball can roll around the inside of the tube so I have

 if(Input.GetKeyDown("right")){
         child.transform.Rotate(transform.forward * 10);
     }
     else if(Input.GetKeyDown("left")){
         child.transform.Rotate(transform.forward * -10);
     } 

So the inner child will rotate, and "gravity" will be applied to its new down, so in theory the ball should be pulled where ever the inside is pointing away from. The ball should be able to stick to the ceiling. And initially it does. The problem is that whenever I try to rotate the ball does not just move and is along the new edge, it starts rocking and spinning and generally going crazy. Is there anyway to stop this spin out with out freezing the rotation, because it will have to roll down the tube?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ScroodgeM · Aug 25, 2012 at 08:44 PM

i'd try to imagine what you are actually doing with this line

child.transform.Rotate(transform.forward * -10);

but can't 8)

methinks you need something like

child.transform.Rotate(Vector3.up * -10);
Comment
Add comment · Show 5 · 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 easilyBaffled · Aug 25, 2012 at 09:06 PM 0
Share

Sorry I wish it were that easy, any i forgot to mention that the tube is along the z axis so this is the proper rotate. But here's a new little wrench it all of it, the ball starts rocking on its x axis even when i dont press anything.

avatar image ScroodgeM · Aug 25, 2012 at 09:14 PM 0
Share
  1. transform.Rotate rotates around transform's self space by default. so check again does your row with this rotation correct

  2. you can (and better do so) freeze unneeded rotations in rigidbody's settings

avatar image easilyBaffled · Aug 26, 2012 at 02:44 AM 0
Share

Yeah its doing the right rotations when it should, and I can't freeze any of the rotations because the tube is random so it might have to turn and any different direction, and the child is just an empty object so it doesn't have a rigidbody. What I think the problem is, is that the tube is an imported object so if I give it a collider, it wraps around the outside and not the inside, so the ball falls through part of the tube and then freaks out. Only I dont know how to fix that in maya or unity.

avatar image ScroodgeM · Aug 26, 2012 at 02:24 PM 0
Share

about collider: does the ball always should be inside a tube? if so, tube should have surface faced inside itself and mesh collider will work properly then.

about issue: need some explain about 'going crazy etc'. may be $$anonymous$$imal shared pack to reproduce issue?

avatar image easilyBaffled · Aug 26, 2012 at 03:08 PM 0
Share

The ball will always be inside the tube, and I tried adding a mesh collider but that's causing its own problems that I am trying to solve here: http://answers.unity3d.com/questions/308191/mesh-collider-maya-import.html the collider doesn't want to wrap on the inside.

Going crazy means that with out touching any buttons, the ball falls a bit(about and 8th) into the tube and starts rocking back and forth slowly but then it picks up and rolls around the tube in random directions and eventually just flys off into the void.

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

8 People are following this question.

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

Related Questions

iOS game: Physics with ConstantForce 1 Answer

Rotating Multiple Objects at once (OnCollision) 1 Answer

Trying to rotate player, how? 0 Answers

I WILL GIVE YOU 3 DOLLARS to answer this constantforce question 4 Answers

Rotate AI towards target, on single axis? 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