39 lines
1.0 KiB
C#
Executable File
39 lines
1.0 KiB
C#
Executable File
using System;
|
|
using JetBrains.Annotations;
|
|
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class testGun : MonoBehaviour
|
|
{
|
|
public GameManager gm;
|
|
public GameObject bullet;
|
|
|
|
public Vector3 bulletSpawn;
|
|
public GameObject spawner;
|
|
Camera camera;
|
|
|
|
ParticleSystem particle; // the current reason for this specifically is to add a smoke effect when shooting
|
|
|
|
GameObject particleSpawn;
|
|
|
|
void Start() {
|
|
Camera camera = FindAnyObjectByType<Camera>();
|
|
Ray ray = camera.ScreenPointToRay(Input.mousePosition);
|
|
ParticleSystem particle = GetComponentInChildren<ParticleSystem>();
|
|
particle.Stop();
|
|
}
|
|
|
|
void Update() {
|
|
bulletSpawn = spawner.transform.position;
|
|
ParticleSystem particle = GetComponentInChildren<ParticleSystem>();
|
|
|
|
if (Input.GetMouseButton(0)) {
|
|
Instantiate(bullet, bulletSpawn, Quaternion.identity);
|
|
particle.Play();
|
|
} // particles do not work
|
|
if (Input.GetMouseButtonUp(0)) {
|
|
particle.Stop();
|
|
}
|
|
}
|
|
}
|