using HQFPSWeapons; using System.Collections; using System.Collections.Generic; using UnityEngine; public class tpsGunData : MonoBehaviour { public string weaponName; public Transform holding_rightHandPosition; public Transform aiming_rightHandPosition; public Transform leftHandPosition; public Transform headTarget; [Header("Shooting Properties")] public GameObject tracerPref; public GameObject muzzleFlashPref; public Transform weaponTip; public Light muzzleLight; public AudioClip[] shotSfxs; public float muzzleLightIntensity = 0; public float muzzleLightMaxIntensity = 2; private void Update() { muzzleLight.intensity = muzzleLightIntensity; if(muzzleLightIntensity > 0) { muzzleLightIntensity -= 0.1f; } } public void triggerMuzzleFlash() { Debug.Log("Muzzle flash message recieved!"); muzzleLightIntensity = muzzleLightMaxIntensity; if (tracerPref != null) { PoolableObject tracer = PoolingManager.Instance.GetObject( tracerPref, weaponTip.position, weaponTip.rotation ); } if (muzzleFlashPref != null) { Quaternion muzzleFlashRot = Quaternion.Euler(new Vector3( Random.Range(0, 180), Random.Range(0, 180), Random.Range(0, 180))); PoolableObject muzzleFlash = PoolingManager.Instance.GetObject( muzzleFlashPref, weaponTip.position, muzzleFlashRot ); } GetComponentInParent().PlayOneShot(shotSfxs[Random.Range(0,shotSfxs.Length)]); // foreach (GameObject go in muzzleFlash) // { // go.SetActive(true); // } // StartCoroutine(disableMuzzleFlashAfterTime(2)); } IEnumerator disableMuzzleFlashAfterTime(float timeInSeconds) { yield return new WaitForSeconds(timeInSeconds); // foreach (GameObject go in muzzleFlash) // { // go.SetActive(false); // } } }