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 XSSA · Jul 11, 2012 at 06:46 AM · gravityplanetforcesworld space

Converting Local to World Forces in gravity simulation.

I have a semi-realistic solution to orbital gravity but it has several problems:

  1. It uses a system that only allows body-body gravity.

  2. It works in local space.

  3. It makes my planets turn unrealistically.

  4. It only works for large objects(planets, moons, stars)

I'd like to find a way to convert the local forces to world forces and store them in variables, then apply them in world space.

I think that I should describe this more in depth, so here we go.

At the moment my system has two spheres of different sizes childed to there own empty objects. The empty object is rotated (problem 3) to face the other's sphere, so the planets turn as the empty object turns and we all know this doesn't happen. Then, a second script uses a function to find the distance between them and does this equation g = (GxM1xM2)/(DxD). This gives output in Newtons, then I divide it by its imaginary mass. Imaginary mass is a mass to large to simulate with the ridgedbody. This gives a force of Newtons equal to Meters per Second Squared if the mass of the ridgedbody is 1kg. Then, I apply this as a constant force in the local Z (problem 2) direction of the empty object (Ridgedbody's mass is set to 1kg). Now, I have gravity! So as the "planet" is childed to the empty object, it will not work for an object (spaceship) that has other forces applied to it (problem 4). Also, it can only face one object at a time. Therefore the force can only be applied in one local z direction. Making it impossible to create a multi-body gravity simulation where a moon pulls on a planet while it gets pulled on by its planet's star (problem 1).

I can put up the scripts if it helps but not if you dont need them. If you need more explantion on a aspect of the system I can supply that to.

Thanks for the help.

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
Best Answer

Answer by ScroodgeM · Jul 14, 2012 at 12:56 PM

why can't you add force to rigidbodies in different directions?

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

you can calculate force for each pair of obects and apply force every FixedUpdate() in relative directions - unique for each pair. also it's better to ignore far-placed pairs to make calculations lighter, close object's gravity is much more powerful then far-placed, so you can ignore it in usual game.

Comment
Add comment · Show 3 · 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 XSSA · Jul 16, 2012 at 03:04 AM 0
Share

this is what i want to accomplish but i'm not sure how to calculate the forces for the individual axis

avatar image ScroodgeM · Jul 16, 2012 at 04:16 AM 0
Share

you have two objects in position pos1 and pos2 (Vector3). just take (pos2-pos1) and you'll got direction from pos1 to pos2, so you must apply force to obj1 in this direction, and to obj2 in opposite direction

http://answers.unity3d.com/questions/284173/distinguish-between-two-colliding-objects.html

just like this but inverse directions

avatar image XSSA · Jul 16, 2012 at 09:36 PM 0
Share

thanks so much for your help at first i was really confused but when i figured out you needed to normalize the vector3 it worked! but now a small and probably obvious question how to you apply a world constant force because it seams i can only apply a relative force and that wont work for a spinning planet or ship? Never $$anonymous$$d i found the answer in the spelling you have to use a lower case when spelling .force facehoof /)-(\

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Finding "UP" while using planetary gravity? 0 Answers

Possible to create axis centered gravity? 1 Answer

Moving object along its own axis 2 Answers

Centric gravity issues... 1 Answer

Planetary based gravity 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