I’m trying come up with a script that will orbit an object around a target, much like the mouseOrbit script that comes with unity, but I need mine to use the orbiting object’s local axes as the rotation axes.

In mouseOrbit the rotation is calculated this way:

```
var rotation = Quaternion.Euler(y, x, 0);
```

but the problem with this is that it will always rotate around absolute world axis so when I’m directly on top of the object it will start to roll instead of orbit which is not the result I’m looking for.

so I tried this:

```
var xRot : Quaternion = Quaternion.AngleAxis(x, transform.up);
var yRot : Quaternion = Quaternion.AngleAxis(y, transform.right);
var finalRot : Quaternion = yRot * xRot;
```

But it goes all crazy as I rotate.

Can anyone give me a hand? I think I’m close I just need to figure out how to properly combine the rotations.