﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class fireBulletsScript : MonoBehaviour
{
    public GameObject bulletPrefab;
    public float shotDelay = 1f;
    double shotTime = 0;

    private float fire;
    public void OnFire(InputAction.CallbackContext context)
    {

        if (Time.timeSinceLevelLoadAsDouble-shotTime > shotDelay)
        {
            var bullet = Instantiate(bulletPrefab, transform.position + (transform.up / 2), transform.rotation);
            bullet.GetComponent<Rigidbody2D>().linearVelocity = transform.up * 6;
            Destroy(bullet, 3f);
            shotTime=Time.timeSinceLevelLoadAsDouble;
        }
    }
}
