zombie_mp/Assets/Scripts/tpsGunData.cs
Sewmina Dilshan 68183e5317 initial
2021-08-23 13:28:33 +05:30

74 lines
2.0 KiB
C#

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 float muzzleLightIntensity = 0;
public float muzzleLightMaxIntensity = 2;
private void Update()
{
muzzleLight.intensity = muzzleLightIntensity;
if(muzzleLightIntensity > 0)
{
muzzleLightIntensity -= 0.1f;
}
}
public void triggerMuzzleFlash()
{
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
);
}
// 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);
// }
}
}