Unity攻击间隔的代码怎么写?

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class shell1n : MonoBehaviour
{
    public GameObject ShellPrefab;//public子弹预制体
    public KeyCode FireKey = KeyCode.Space;//FireKey设置为空格键
    public float shellSpeed = 10;//子弹速度为10
    private Transform firePoint1;//发射位置FirePoint1
    public GameObject sphereshellExplosionPrefab;//public子弹爆炸粒子效果预制体
    public bool Fire1 = true;//子弹发射许可设置为true
    public float jiangetime = 3.0f;//攻击间隔jiangetime设置为3.0秒

    void Start()
    {
        firePoint1 = transform.Find("FirePoint1");//自动寻找发射位置FirePoint1        
    }
    void Update()
    {
        if (Fire1 == true)//如果子弹发射许可为ture,执行下方内容
        {
            if (Input.GetKeyDown(FireKey))//如果按下了FireKey,执行下方内容
            {
                Fire1 = false;//攻击后进入间隔,子弹发射许可设置为false
                GameObject go = GameObject.Instantiate(ShellPrefab, firePoint1.position, firePoint1.rotation) as GameObject;//在发射点位置实例游戏对象ShellPrefab。
                go.GetComponent<Rigidbody>().velocity = go.transform.forward * shellSpeed;//给予子弹初速度
//(这里这里!!!!!!我是第28行!!!!!!!!!!)//攻击间隔,等待jiangetime,时间达3.0秒
                Fire1 = true;//攻击间隔冷却结束,子弹发射许可设置为ture
            }
        }
    }
    public void OnTriggerEnter(Collider collider)
    {
        GameObject.Instantiate(sphereshellExplosionPrefab, transform.position, transform.rotation);//实例化爆炸效果
        GameObject.Destroy(this.gameObject);//删除子弹
    }
}


运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

我要在第28行代码填写什么,才能在Unity中达成按下FireKey后,三秒钟内按下FireKey按键无反应?
求简短一点,如果没有这样的代码,能不能给可怜的题主指一个这种代码的教程?

给你代码做了修改,有用请采纳!


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class shell1n : MonoBehaviour
{
    public GameObject ShellPrefab;//public子弹预制体
    public KeyCode FireKey = KeyCode.Space;//FireKey设置为空格键
    public float shellSpeed = 10;//子弹速度为10
    private Transform firePoint1;//发射位置FirePoint1
    public GameObject sphereshellExplosionPrefab;//public子弹爆炸粒子效果预制体
    public bool Fire1 = true;//子弹发射许可设置为true
    public float jiangetime = 3.0f;//攻击间隔jiangetime设置为3.0秒

    void Start()
    {
        firePoint1 = transform.Find("FirePoint1");//自动寻找发射位置FirePoint1        
    }
    float time = 0;//时间累加
    void Update()
    {
        if (Input.GetKeyDown(FireKey))//如果按下了FireKey,执行下方内容
        {
            if (Fire1)
            {
                Fire1 = false;//攻击后进入间隔,子弹发射许可设置为false
                GameObject go = GameObject.Instantiate(ShellPrefab, firePoint1.position, firePoint1.rotation) as GameObject;//在发射点位置实例游戏对象ShellPrefab。
                go.GetComponent<Rigidbody>().velocity = go.transform.forward * shellSpeed;//给予子弹初速度     
            }
        }
        else if (!Fire1)
        {
            time += Time.deltaTime;
            if (time>jiangetime)//大于你的时间间隔3秒按下空格键才可以发射子弹
            {
                Fire1 = true;
                time = 0;
            }
        }
    }
    public void OnTriggerEnter(Collider collider)
    {
        GameObject.Instantiate(sphereshellExplosionPrefab, transform.position, transform.rotation);//实例化爆炸效果
        GameObject.Destroy(this.gameObject);//删除子弹
    }
}