Camera Smooth Zoom Ontrigger
I'm new to unity programming and I was wondering how to smoothly zoom in OntriggerStay and smoothly zoom out onTriggerExit.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CameraZoom : MonoBehaviour {
public Camera cameraZoom;
public bool Enterbool;
void Start()
{
cameraZoom = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
}
public void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "Player")
{
Enterbool = true;
cameraZoom.orthographicSize = 16;
}
}
public void OnTriggerExit(Collider other)
{
cameraZoom.orthographicSize = 20;
Enterbool = false;
}
}
Any help would be grateful, thanks.
Comment
Your answer
Follow this Question
Related Questions
How to make camera follow player from point to point 2 Answers
Camera moving OnTriggerEnter 2 Answers
Making a Smooth camera zoom with transform.Translate 1 Answer
Camera Shake on trigger 0 Answers