I’ve implemented player movement, as well as three different rooms. I understand how to create a first and third person camera, but how can I make three different camera views to track the player from room to room?
More specifically, is there a way to zoom in on each room when the corresponding button is clicked?
So far I have a separate script attached to the main camera with this code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cameraControls : MonoBehaviour
{
public GameObject player;
//private Vector3 offset;
public bool greenRoom;
public bool blueRoom;
public bool purpleRoom;
void OnGUI()
{
// Room 1 (Green room)
if (GUI.Button(new Rect(20, 50, 140, 40), "Green Room Camera"))
{
greenRoom = true;
blueRoom = false;
purpleRoom = false;
}
// Room 2 (Blue room)
if (GUI.Button(new Rect(20, 110, 140, 40), "Blue Room Camera"))
{
blueRoom = true;
greenRoom = false;
purpleRoom = false;
}
// Room 3 (Purple room)
if (GUI.Button(new Rect(20, 110, 140, 40), "Purple Room Camera"))
{
blueRoom = false;
greenRoom = false;
purpleRoom = true;
}
}
// Start is called before the first frame update
void Start()
{
//offset = transform.position - player.transform.position;
}
// Update is called once per frame
void Update()
{
if (greenRoom == true && blueRoom == false && purpleRoom == false)
{
}
if (blueRoom == true && greenRoom == false && purpleRoom == false)
{
}
if (purpleRoom == true && blueRoom == false && greenRoom == false)
{
}
}
}