# 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.

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!

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.