Camera random rotate around object

Hello,

I try to create a camera, which rotates random around an object with random zoom. The camera should circle all the time. The min/max distance is fix to the object and the camera should not flip over itself. But it does not work. Please can somebody help.

void Update () {

	float radius = Random.Range (5, 20);
	Vector3 target = Random.insideUnitSphere * radius;
	Vector3 current = transform.position;
	transform.position = Vector3.MoveTowards (current, target, speed);
}

For the rotation you can put the camera inside of a gameObject, and rotate the gameObject.
Remember that the camera need to be facing to the gameObject parent. (x and y axis).

But the zoom (in z axis), you can manipulate with the random range.

void Update () {

	float zoom = Random.Range (5, 10);
	float currentPosition = transform.position.z;
	transform.position = new Vector3 (0, 0, Mathf.Lerp(currentPosition, zoom, Time.deltaTime * speed));

	targetAngle = Random.rotation;
	currentAngle = new Vector3 (
		Mathf.LerpAngle (currentAngle.x, targetAngle.x, Time.deltaTime * speed),
		Mathf.LerpAngle (currentAngle.y, targetAngle.y, Time.deltaTime * speed),
		0);

	transform.eulerAngles = currentAngle;
	
}

Thanks for your answer, but it does not work in my script. The camera is not circling around an object :frowning: