Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Ederitosss · Feb 10, 2016 at 01:37 PM · physicsorbitprediction

How can i predict an Orbit?

Hello, Sorry but my english is a mess. I am trying to Predict and draw the orbit of a rigidbody around another but i cant getit... If somebody can give me a clue, that be great The orbital fuction is the same as the natural laws using the phisics included in the engine and works awesome, but i cant draw the orbit, i know how to use the linerenderer component.

what is the function throught time variable to calculate the points?

MASS = Orbiting Object`s mass RB.mass = Planet Mass. dir = direction of planet from orbiting object Distance = Distance between bodies.

RealGravity = ((Gravity) (RB.mass MASS)) / (Distance*Distance); RB.AddForce((dir) * RealGravity, ForceMode.Force);

Thanks!

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

Answer by Erethan · Feb 15, 2016 at 05:07 AM

Since your acceleration varies, position in respect to time formula is not that simple, However, you can do a trick to do the job.

You have it's start position and initial velocity. From RealGravity * dir and mass, you can find acceleration in the direction of the planet in the launch. So if you consider acceleration CONSTANT for a small change in time, you can find the next position of your LineRender with the formula below;:

S = So + v*t + (a a t)/2

The method below will return the Vector3[] that you need to assign in your Line Renderer. You choose how many points you will need and how close they will be together from each other. Increase timeInterval for a better approximation

 Vector3[] TrajectoryPrediction(int points, float timeInterval)
 {
      Vector3[] final =  new Vector3[points];
      final[0] = launch.position;
      Vector3 considVel = initialVelocity;//You have this from the impulse force you would add
 
      for(i = 1; i < points;i++)
      {
           final[i] = final[i -1] + considVel * timeInterval + (g* g) * dir * timeInterval; 
           //g should be a method like your RealGravity used only for this prediction. It will use final[i-1] as      the object's position for the distance and it will be without rb.mass as it will be canceled out when a=F/mass
 
           considVel = considVel + RealGravity * timeInterval;
 
      }
      return final;
 }



*The script above is not optimized as I am using here to teach a concept

Comment
Add comment · Show 4 · 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 valiantjohn123 · Mar 25, 2018 at 02:49 PM 0
Share

Awesome, it's working like a charm.

avatar image al-X valiantjohn123 · Sep 06, 2019 at 08:55 PM 0
Share

how did ya get it to work?

avatar image Bunny83 al-X · Sep 07, 2019 at 12:03 AM 0
Share

What do you mean? This is exactly what I suggested at the end of the answer I wrote to your question. However you haven't commented back yet. This simply fast-forwards the simulation a certain amount of steps. You just give the method the number of points you want and the time interval between two points. Of course the time interval shouldn't be too large to get a good approximation.

Show more comments

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

Calculating trajectory of elliptical orbit? 2 Answers

Constrain rigid body movement to a sphere 3 Answers

Kepler's law, orbit speed 1 Answer

How to make an orbital movement as smoothly as possible? 0 Answers

Help with orbit path predictor 2 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