How to orbit camera around player from top-down to sidescroller view?

Hello, first timer here. I’ve seen a couple of posts on orbiting objects
(perhaps not enough), but thought I’d rather elaborate on what I would like
to do. Say I want the main camera to move in an orbiting fashion around the
player from a side-scroller view, to a top-down view and vice versa, when
the player (a hovering object) is at a certain height from terrain. Any ideas?

(I haven’t really written anything in the cam script yet…)

I seem to have solved my problem. The truth is I got caught between complex spherical coordinate and orbital equations that I blinded myself from simple solution provided by Unity and the awesome Unity Answers community. Here’s what I wanted to do and how I solved it:

The project is in a 3D environment, and it should alternate between a sort 3/4 top-down view and
side-scroller view, depending on height and a certain in game situation. So I needed the camera to execute rotation when the player’s height reached 200f off the terrain. If going up, camera should rotate to the top-view, and side-scroller when moving down below 200f height.

Its very basic, and if someone has a better way to do it, please do elaborate! I’ll be grateful for your assistance. I hope this helps someone out there.

Here’s how I solved it in steps:

  1. Create a 3D Sphere object and Reset Position
  2. Disable its Mesh Renderer
  3. Enable ‘is Trigger’ in the Sphere Collider
  4. Reset the desired camera’s position
  5. Make the camera a child of the Sphere object.
  6. Move the camera to a desired offset from the Sphere’s center (doesn’t have to be within the sphere boundary)
  7. Move the center of the sphere object to the center of the player object
  8. Add a new script component to the Sphere object for movement.

Here’s the script (it is not commented tho):

using UnityEngine;
using System.Collections;

public class CamSphereMovement : MonoBehaviour {

	public Transform uTransform;
	private HoverEngine hoverEngine;
	private GameObject uPlayer;

	public float xRot { get; private set; }
	private float cameraZ;

	private bool camFlip = false;

	
	// Use this for initialization
	void Start () {
		uPlayer = GameObject.FindWithTag("Player");
		uTransform = uPlayer.transform;
		hoverEngine = uPlayer.GetComponent<HoverController>().hoverEngine;
		cameraZ = transform.position.z;
	}
	
	
	void LateUpdate () {
		transform.position = new Vector3(uTransform.position.x, uTransform.position.y, cameraZ);

		if (camFlip == false) {
			if (hoverEngine.hoverHeight.y > 200f && transform.localEulerAngles.x < 65f) {
				transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler (65f, 0f, 0f), 10f * Time.deltaTime);
			} else {
			camFlip = true;
			}
		} else {
			if (hoverEngine.hoverHeight.y < 200f && transform.localEulerAngles.x > 0f) {
				transform.rotation = Quaternion.RotateTowards (transform.rotation, Quaternion.Euler (0f, 0f, 0f), 10f * Time.deltaTime);
			} else {
			camFlip = false;
			}
		}
	}
}