Initial commit
This commit is contained in:
31
Assets/Scripts/KeyPickup.cs
Normal file
31
Assets/Scripts/KeyPickup.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class KeyPickup : MonoBehaviour
|
||||
{
|
||||
public static bool HasKey = false;
|
||||
|
||||
[SerializeField] private GameObject pickupEffect;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (!other.CompareTag("Player")) return;
|
||||
|
||||
HasKey = true;
|
||||
|
||||
if (pickupEffect != null)
|
||||
{
|
||||
GameObject effect = Instantiate(
|
||||
pickupEffect,
|
||||
transform.position,
|
||||
Quaternion.identity
|
||||
);
|
||||
|
||||
Destroy(effect, 3f);
|
||||
}
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user