How to use Rotate.Around on a moving object.

I am using rotate.around to move a cube around another cube. This works fine of course until the cube I am rotating around is moved whereby the rotating cube just keeps on going around the original point. I have tried setting it to have a target and then taking that transform.position but just can't get it to work. Any help would be appreciated.

I suspect you have had this all along but are doing what I always do which is mistype target : Transform by typing target = Transform. Maybe not but check as I always make this mistake.

This should work fine (well it does for me for moons and planets etc).

var degrees = 10;
var target : Transform;

function Update() {

    transform.RotateAround (target.position, Vector3.up, degrees * Time.deltaTime);


Try this:

var targetCube : Transform;

function Update() {

    // spin the object around the target at 100 degrees/second.

    transform.RotateAround (targetCube.transform.position, Vector3.up, 100 * Time.deltaTime);

    if (Input.GetKey (KeyCode.UpArrow)) {
    	targetCube.transform.position.x = targetCube.transform.position.x +  1;
    if (Input.GetKey (KeyCode.DownArrow)) {
    	targetCube.transform.position.x = targetCube.transform.position.x -  1;


If you also change the position of the rotating cube, the distance between both cubes will stay constant while the rotation is maintained.