# using mouseorbit script and Rotate Around with specific angle

I'm using the MouseOrbit script (modified) from Standard Assets to rotate an object around another. I want the object that is rotating to do so at a specific angle (say 45 degerees) but cannot accomplish this. Code is below... can anyone help?

``````var target : Transform;
var distance = 4.0;

var xSpeed = 250.0;
var ySpeed = 120.0;

var yMinLimit = -20;
var yMaxLimit = 80;

private var x = 0.0;
private var y = 0.0;

function Start () {
var angles = transform.eulerAngles;
x = angles.y;
y = angles.x;

// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}

function LateUpdate () {
if (target) {
x += .1 * xSpeed * 0.02;
y -= 0;

y = ClampAngle(y, yMinLimit, yMaxLimit);

var rotation = Quaternion.Euler(y, x, 0);
var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;

transform.rotation = rotation;
transform.position = position;
}
}

static function ClampAngle (angle : float, min : float, max : float) {
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp (angle, min, max);
}

``````

Figured out a much easier function

``````transform.RotateAround (GameObject.Find("your object to orbit around").transform.position, Vector3(Mathf.Tan(oAngle * Mathf.Deg2Rad), 1, 0), Time.deltaTime * oSpeed);

``````

oAngle is the angle for rotation oSpeed is the speed of the orbiting object.

Basically this script finds the tangent of the angle in radians, converts that to degrees and moves the object accordingly