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 /
This question was closed Jul 18, 2013 at 01:59 AM by robertbu for the following reason:

Question too broad

avatar image
0
Question by CupOfMayo · Jul 17, 2013 at 11:10 PM · gravity

How to make one object pull another (gravity)?

Hey, I was searching for some planetary gravity sctipts, but any of this what i found didnt work... So once again I need help. All what i want to do is to make one object pull a player. The game is about flying simple rocket what use rigidbody to move, and I want to make it able to orbit arround not big sphere. If it is possible i wish it was a java script and kinda simple (i only hope it will be simple, because pulling one object to another sounds easy) Sorry for my bad english! :/

Comment
Add comment · Show 4
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 Benproductions1 · Jul 18, 2013 at 01:44 AM 0
Share

Ins$$anonymous$$d of saying "I need help!" How about you post the code, that "does not work" and we can work through fixing it.

As of now, the only answer you will get is: Apply force to the object using the gravitational force formula

avatar image robertbu · Jul 18, 2013 at 01:58 AM 0
Share

Google "unity3d planetary gravity," and do some research. There are multiple approaches, and a number of interesting posts in UA on this question. As it stands now, your question is too broad for an answer, plus UA is about helping you solve your own problem, not writing a script for you. If in researching this issue you have specific technical issues, we welcome a new, focused question.

avatar image CupOfMayo · Aug 16, 2013 at 02:36 PM 0
Share

Well, I know it's already closed, but quite a time ago i found a solution: var Planet : GameObject; var force : float = -0.1;

 function Update () 
 {
         rigidbody.AddForce ((transform.position - planet.transform.position).normalized * force * rigidbody.mass, Force$$anonymous$$ode.Impulse);
         
        
 }
avatar image Commander5518 · Feb 16, 2014 at 11:15 PM 0
Share

Thank you that worked ^^

1 Reply

  • Sort: 
avatar image
-2

Answer by pborg · Jul 18, 2013 at 06:59 AM

I worked on a game a few months ago that involved using orbit as at tool. Our team member in charge of creating the orbit physics did all sorts of research in applying forces. We ended up just setting the rocket to the child of the planet. All rotation and movement applied to the planet will cause the rocket to orbit around it and move with it respectively. Amazingly simple, just drag the rocket onto the planet in the editor or via script: //rocket script

 var planet : Transform;
 function Start()
 {
    //use find techniques to get the planet
    transform.parent = planet;
 }

I hope this helps. If you or anybody else wants to ask any other questions, or comment on something I missed, feel free!

Comment
Add comment · Show 2 · 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 Benproductions1 · Jul 18, 2013 at 10:17 AM 0
Share

No offence, but your $$anonymous$$m member must not be very good. It's quite easy finding the velocity needed to stay within orbit of a object with a gravitational field. It's all explained right here
But then again, rigidbody physics might be to inaccurate for a proper orbit ;)

Also your answer does not answer the question. The questions said: "implement gravity" not "make orbit", sorry, but I'm gonna have to give a -1

avatar image pborg · Jul 18, 2013 at 06:08 PM 0
Share

@$$anonymous$$roductions " and I want to make it able to orbit arround not big sphere. If it is possible i wish it was a java script and kinda simple"

Follow this Question

Answers Answers and Comments

18 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Adding a jump feature help? 2 Answers

how to add gravity to this script 2 Answers

How to change gravity direction on Character Motor 0 Answers

Gravity - How to walk on ceiling 1 Answer

3D Gravity towards one object 3 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