<repo_name>mcumiskey/Unity_Museum_Tour<file_sep>/GalleryDemo/Assets/scripts/milesMouseLook.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class milesMouseLook : MonoBehaviour {

    
    [SerializeField]
    public float sensitivity = 5.0f;
    [SerializeField]
    //Time.deltaTime makes smoothing framerate indipendant 
    public float smoothing = 2.0f;
    // the chacter is the tube 
    public Transform player;
    // get the incremental value of mouse moving
    private Vector2 mouseLook;
    private float xRotation = 0f;

	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
        
        //use the mouse to determine x and y
        float mouseX = Input.GetAxis("Mouse X") * sensitivity * smoothing;
        float mouseY = Input.GetAxis("Mouse Y") * sensitivity * smoothing;

        // the interpolated float result between float values
        xRotation = Mathf.Lerp(xRotation, mouseY, 1f / smoothing);
        // incrementally add this to the camera look
        mouseLook.y -= xRotation;
        //do not allow mouseLook.y to exceed -90 to 90 degrees
        if(mouseLook.y > 90){
            mouseLook.y = 90;
        }
         if(mouseLook.y < -90){
            mouseLook.y = -90;
        }

        // vector3.right means the x-axis
        //the transform is for the camera the script is attached to
        transform.localRotation = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
        //this rotates the chatracter (and the camera) left + right
        player.Rotate(Vector3.up * mouseX);
    }

    
}
<file_sep>/GalleryDemo/Assets/Scripts/SelectionControl.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class SelectionControl : MonoBehaviour {

    [SerializeField] public GameObject textGUI;
    [SerializeField] public GameObject camera;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        if(Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity)){
            GameObject selection = hit.transform.gameObject;
            Debug.Log("hit " + selection.tag);
            if(selection.CompareTag("Art")){
                textGUI.SetActive(true);
            } else {
                textGUI.SetActive(false);

            }

        }
    }
}
