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(); Ray ray = camera.ScreenPointToRay(Input.mousePosition); ParticleSystem particle = GetComponentInChildren(); particle.Stop(); } void Update() { bulletSpawn = spawner.transform.position; ParticleSystem particle = GetComponentInChildren(); if (Input.GetMouseButton(0)) { Instantiate(bullet, bulletSpawn, Quaternion.identity); particle.Play(); } // particles do not work if (Input.GetMouseButtonUp(0)) { particle.Stop(); } } }