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:
Create a 3D Sphere object and Reset Position
Disable its Mesh Renderer
Enable ‘is Trigger’ in the Sphere Collider
Reset the desired camera’s position
Make the camera a child of the Sphere object.
Move the camera to a desired offset from the Sphere’s center (doesn’t have to be within the sphere boundary)
Move the center of the sphere object to the center of the player object
Add a new script component to the Sphere object for movement.