Select Git revision
Physics2DSettings.asset
ShopColliderDetection.cs 1019 B
using UnityEngine;
using TMPro;
using System.Collections;
public class ColliderChecker : MonoBehaviour
{
public GameObject shopKeeper;
public Canvas shopInstructionCanvas;
public TMP_Text instructionText;
public SaveRadius saveRadius;
void Update()
{
// Check if the targetObject is within the collider of this GameObject
if (!GetComponent<Collider>().bounds.Intersects(shopKeeper.GetComponent<SphereCollider>().bounds))
{
if ((Input.GetKeyDown(KeyCode.Z) || Input.GetButton("X Button")) && Time.timeScale == 1 && !saveRadius.playerInRange)
{
StartCoroutine(ErrorMessage());
}
}
}
IEnumerator ErrorMessage()
{
instructionText.text = "Shop is out of range";
shopInstructionCanvas.gameObject.SetActive(true);
yield return new WaitForSeconds(2f);
shopInstructionCanvas.gameObject.SetActive(false);
instructionText.text = "Press Z to open the shop";
}
}