using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShootPlayer : MonoBehaviour
{
[SerializeField] private GameObject bulletPrefab;
private float timeSinceLastShot = 0f;
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Shoot();
}
timeSinceLastShot += Time.deltaTime;
}
void Shoot()
{
if (timeSinceLastShot >= 0.6f)
{
GameObject bullet = Instantiate(bulletPrefab, transform.position, transform.rotation);
bullet.layer = gameObject.layer;
timeSinceLastShot = 0f;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShootPlayerPurple : MonoBehaviour
{
[SerializeField] private GameObject bulletPrefab;
float timeSinceLastShot = 0f;
private void Update()
{
if (Input.GetKeyDown(KeyCode.X))
{
Shoot();
}
timeSinceLastShot += Time.deltaTime;
}
void Shoot()
{
if (timeSinceLastShot >= 5.3f)
{
GameObject bullet = Instantiate(bulletPrefab, transform.position, transform.rotation);
bullet.layer = gameObject.layer;
timeSinceLastShot = 0f;
}
}
}