Your comments

Ah I see! For the second question, will the custom script go into the Main Camera or FirstPersonController provided by game4automation or my object? And what public variables would be required? I have attempted various scripts but all does not seem to be working. I look forward to your response. Please see below:

Script 1:

using UnityEngine;

public class ZoomEffect : MonoBehaviour {
Vector3 groundCamOffset;
Vector3 camTarget;
Vector3 camSmoothDampV;

public Camera mainCamera;

private Vector3 GetWorldPosAtViewportPoint(float vx, float vy)
{
Ray worldRay = mainCamera.ViewportPointToRay(new Vector3(vx, vy, 0));
Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
float distanceToGround;
groundPlane.Raycast(worldRay, out distanceToGround);
Debug.Log("distance to ground:" + distanceToGround);
return worldRay.GetPoint(distanceToGround);
}

void Start() {
Vector3 groundPos = GetWorldPosAtViewportPoint(0.5f, 0.5f);
Debug.Log("groundPos: " + groundPos);
groundCamOffset = mainCamera.transform.position - groundPos;
camTarget = mainCamera.transform.position;
}

void Update() {
if (Input.GetMouseButtonDown(0)) {
// Center whatever position is clicked
float mouseX = Input.mousePosition.x / mainCamera.pixelWidth;
float mouseY = Input.mousePosition.y / mainCamera.pixelHeight;
Vector3 clickPt = GetWorldPosAtViewportPoint(mouseX, mouseY);
camTarget = clickPt + groundCamOffset;
}

// Move the camera smoothly to the target position
mainCamera.transform.position = Vector3.SmoothDamp(
mainCamera.transform.position, camTarget, ref camSmoothDampV, 0.5f);
}
}

Script 2:

using System.Collections;

using UnityEngine;

public class ZoomEffect : MonoBehaviour
{
public float movespeed = 35.0f;
//you need to say how far from the object the camera will stop
public float minimumDistanceFromTarget = 5f;
public GameObject targetobject;
private bool movingtowardstarget = false;

// Use this for initialization
void Start()
{
}

// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(1))
{
if (movingtowardstarget == true)
{
movingtowardstarget = false;
}
else
{
movingtowardstarget = true;
}
}

if (movingtowardstarget)
{
movetowardstarget(targetobject);
}
}

public void movetowardstarget(GameObject target)
{
if(Vector3.Distance(transform.position, target.transform.position) > minimumDistanceFromTarget) //we move only if we are further than the minimum distance
{
transform.position = Vector3.MoveTowards(transform.position, target.transform.position, movespeed * Time.deltaTime);
} else //otherwise, we stop moving
{
movingtowardstarget = false;
}
}
}

Hey, some more clarification below!

1. I believe I was able to figure out how to switch between first person and orbit controls. But, in the first person view, it does NOT jump for some reason. How to fix this and make it jump when the space bar is pressed?

2. I am trying to get an option where if the user double right clicks on a game object, the camera zooms in and only focuses on this object. For example, if I double right click on the robot arm, the camera will zoom into this robot arm and focus on it, the user can still rotate the camera only around this robot arm object. How to add this? Will greatly appreciate your help.