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 busychild · Jun 21, 2012 at 06:52 PM · physicsrotatemovesphere

Rotate multiple objects around or rather move them on the surface of another object

Hi folks,

i'm currently running into some trouble and i hope you could help me.

I would like to rotate multiple objects around another object NON-spherically but elliptically. Let's assume i've a sphere which is scaled X=100, Y=30, Z=50 and i would like the other objects (about 100 or more) to rotate around or rather move on the surface of the sphere.

As my english is very weak and i'm unable to explain that in a better way, here comes a picture showing what i'm talking about.

alt text

So the objects should always be arranged like a "cloud" and move on the surface while touching or moving the mouse.

Currently i've attached a Behaviour-Script to each of the items:

 if ((Input.GetMouseButton (0) || Input.touchCount == 1) && cloudStatus != CloudMode.Zoom) {
  touchSpinHandler();    
 }

 void touchSpinHandler(){
     transform.RotateAround (Vector3.zero, Vector3.up, fingerPositionX * -Time.deltaTime * (spinSpeedFactor));
     transform.RotateAround (Vector3.zero, Vector3.left, fingerPositionY * -Time.deltaTime * (spinSpeedFactor));
 }



The second step i've to manage is some kind of "physics" which means, while i'm moving my finger faster, the objects should move closer to the center of the sphere and vice versa.

I would appreciate if some of you Unity3D-experts could tell me how to do that.

Thank you all in advance and have a great evening!

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 sweatyrat · Jun 29, 2012 at 05:42 PM

well i would say that what want is Transform.lossyScale or Transform.localScale multiplied by a unit vector in the direction of where you want the object to be on the surface of the other object. so first you can just scatter your objects anywhere around your target object and then use that transform.RotateAround function to rotate the objects and then in the next line take the (transform.position-target.transform.position).normalized to get a unit vector that goes from the target to your object then multiply that by target.transform.lossyScale or target.transform.localScale and set transform.position = that

because (transform.position-target.transform.position).normalized * target.transform.localScale is going to be the position of that object clamped onto the surface of the target object

then you rotate them and clamp them again. and so on.

then to make them get closer to the center you just multiply (transform.position-target.transform.position).normalized * target.transform.localScale by some float from 0 to 1 where 0 is the fastest and at the center of the object and 1 is at the surface of the object.

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

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

Making a sphere move and rotate like a real ball on ground 2 Answers

Rotate and move the sphere while the up key is pressed 1 Answer

Move sphere with independent orientation 1 Answer

Compound Collider Moving Parts? 4 Answers

Make sphere rotate when controlled 7 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