first commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Collectible : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private int scoreValue = 1;
|
||||
[SerializeField] private bool destroyOnPickup = true;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (!other.CompareTag("Player"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UIManager uiManager = FindObjectOfType<UIManager>();
|
||||
if (uiManager != null)
|
||||
{
|
||||
uiManager.AddScore(scoreValue);
|
||||
}
|
||||
|
||||
Debug.Log($"Collected {name} for {scoreValue} point(s).");
|
||||
|
||||
if (destroyOnPickup)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user