//Jimmy Vegas Unity Tutorial //This script will collect the gem using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CollectGem : MonoBehaviour { public float TheDistance; public GameObject ActionDisplay; public GameObject ActionText; public GameObject ExtraCursor; public GameObject TheGem; public AudioSource CollectSound; void Update () { TheDistance = PlayerCasting.DistanceFromTarget; } void OnMouseOver() { if (TheDistance <= 3) { ActionDisplay.SetActive(true); ActionText.SetActive(true); ExtraCursor.SetActive(true); } else { ActionDisplay.SetActive(false); ActionText.SetActive(false); ExtraCursor.SetActive(false); } if (Input.GetButtonDown("Action")) { if (TheDistance <= 3) { CollectSound.Play(); TheGem.SetActive(false); ActionDisplay.SetActive(false); ActionText.SetActive(false); ExtraCursor.SetActive(false); } } } void OnMouseExit() { ActionDisplay.SetActive(false); ActionText.SetActive(false); ExtraCursor.SetActive(false); } }