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 ROM · Aug 03, 2010 at 06:47 PM · rotationspherejointspring

Rotating object between two points?

Basically I have two spheres with a cube between them. One sphere links to the other sphere using a "Spring joint" and moves around it (imagine a planet in orbit). What I want is the cube to stay between them and to rotate accordingly so it always faces the central sphere. How would I do this?

(i've tried making the cube a child of the sphere but it just messed it all up)

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 e-bonneville · Aug 03, 2010 at 08:26 PM 0
Share

You could use another joint between the cube and the central sphere, and then use transform.LookAt to make sure it is always pointed in the right direction.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by SinisterRainbow · Jun 14, 2013 at 05:33 AM

(edited for formatting reasons:) All you need to do is grab the position vector from sphere A and sphere B then add them and divide by 2 to get the position vector for the box. (pseudo code:), then have BOX.lookat(A) as e.bonneville suggested. There are some great tuts on Vector math to learn the basics of things like this, will make game programming much more fun and easy.

In other words:

  GameObject sphereA, sphereB, BoxOne;
     ...
     Vector3 midpoint = (sphereA.transform.position + sphereB.transform.position) / 2;
     BoxOne.transform.position = midpoint;
     Box.transform.LookAt(sphereA.transform);
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 SinisterRainbow · Jun 17, 2013 at 12:19 PM 0
Share

Did this answer your question okay? If so, can you mark it answered, otherwise it remains in the unanswered questions pile.

avatar image Akravator · Aug 12, 2020 at 08:50 AM 0
Share

@SinisterRainbow Sorry to resurrect this thread, but do you know how to do it via configurable joint?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Rolling sphere keep velocity but slow rotation 1 Answer

Roll-a-Ball Tutorial Camera still doing loop de loop as it follows the sphere. 1 Answer

Joint confusion - Bobble head 0 Answers

Third person follow camera on a sphere 1 Answer

Sphere rotation in moving direction 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