Transform.RotateAround axis calculation

alt text

I would like to use function RotateAround (point : Vector3, axis : Vector3, angle : float) : void for orbiting script for simple 3D orbiting :slight_smile:
Can anyone suggest an algorithm for calculation of Transform.RotateAround axis : Vector3 so that the orbital plane passes through the point : Vector3? I find solution for cases where orbital object belongs to the axis but confused when all of its position coordinates != 0.

3D orbiting scripts will be appreciated too :slight_smile:

Well there are two differing ways I can imagine this working.

The hard way would be to restructure the parent-daughter relationship of the objects and only rotate the parent. That’s honestly a cannonball-to-kill-a-fly approach though.

I would suggest using a Quaternion.Euler. Basically setup the pivot location as a quaternion and apply a Eular style change in rotation to the group as a whole.

Something like:

Game object A = Pivot Point 1
Game object B = Pivot Point 2

Both game objects are parented to a master object.

Create a quaternion.eular change based on the positions and apply the results to the master object.

It seems to be the smartest way I can think of, without disrupting your programming too much.