I need help placing a cool down on a destroy object code I made.
I want to make it where the player has to wait X amount of time to be able to destroy another object.
I’m using C# if it wasn’t obvious.
using UnityEngine;
using System.Collections;
public class RaycastBreak : MonoBehaviour {
void Update() {
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray,out hit, 5))
{
if(hit.collider.gameObject==gameObject) Destroy(gameObject);
}
}
}
}
Any suggestions or answers are greatly appreciated