Files
ClearTheZone/Assets/Scripts/Shoot.cs
T

35 lines
841 B
C#

using Unity.VisualScripting;
using UnityEngine;
public class Shoot : MonoBehaviour
{
[SerializeField] GameObject bulletPrefab;
[SerializeField] Transform spawnPointAR;
[SerializeField] Transform spawnPointPistol;
[SerializeField] bool AR = true;
[SerializeField] bool Pistole = true;
void Start()
{
}
void Update()
{
if ( AR == true && Input.GetKey(KeyCode.Mouse0))
{
Shot(spawnPointAR);
}
else if (Pistole == true && Input.GetKeyDown(KeyCode.Mouse0))
{
Shot(spawnPointPistol);
}
}
public void Shot(Transform spawnPoint)
{
GameObject bullet = Instantiate(bulletPrefab, spawnPoint.position, spawnPoint.rotation);
bullet.transform.Rotate(90,0,0);
Destroy(bullet, 2);
}
}