Hi, I have a variable that when it changes, I want the position of my camera to update to the new position. But… its not changing. My debug’s show that its not the variable that is the problem, the variable is updating correctly, but the camera is not moving. Please help!
//Camera locations per room
private Vector3 bathroomView = new Vector3(-0.5f, -1f, -24.5f);
private Vector3 kitchenView = new Vector3(97.5f, -1f, -24.5f);
private Vector3 bedroomView = new Vector3(195.5f, -1f, -24.5f);
//Reference for the position of the camera which will be moved
Vector3 mainCam;
// Use this for initialization
void Start ()
{
guiObject = GameObject.Find("GUI");
drawGui = guiObject.GetComponent<DrawRoomGUI>();
mainCam = GameObject.Find("Main Camera").transform.position;
}
// Update is called once per frame
void Update ()
{
UpdateCameraToRoom(drawGui.selectedRoom);
print (drawGui.selectedRoom);
}
//This function moves the camera to the new room cube that we have selected
void UpdateCameraToRoom(string selectedRoom)
{
//Switch what view the camera has depending on what room we have selected in the DrawRoomGUI
switch(selectedRoom)
{
case "Bathroom":
mainCam = bathroomView;
break;
case "Kitchen":
mainCam = kitchenView;
break;
case "Bedroom":
mainCam = bedroomView;
break;
default:
mainCam = bathroomView;
break;
}
}