Files
MagicDog/Assets/Scripts/Chest.cs
2026-04-14 16:37:06 +02:00

31 lines
683 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;
public class Chest : MonoBehaviour
{
private GameManager _gameManager;
private void Awake()
{
_gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
Assert.IsNotNull(_gameManager);
}
private void OnTriggerStay(Collider other)
{
Debug.Log("Triggered");
if (!Input.GetKeyDown(KeyCode.Space))
{
return;
}
if (!other.name.Equals("Player"))
{
return;
}
_gameManager.OpenChest();
Destroy(gameObject);
}
}