2022-10-24 19:58:29 -04:00

35 lines
755 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Collectible : MonoBehaviour
{
[SerializeField]
private int amount;
[SerializeField]
private float rotSpeed;
[SerializeField]
private float timeToAppear;
void Update()
{
transform.Rotate(0, rotSpeed, 0, Space.World);
}
private void OnTriggerEnter(Collider other) {
if(other.gameObject.tag.Equals("Player")){
other.gameObject.GetComponent<GrappleHook>().AddCharge(amount);
Vanish();
}
}
private void Vanish(){
gameObject.SetActive(false);
Invoke("Appear", timeToAppear);
}
private void Appear(){
gameObject.SetActive(true);
}
}