private void OnCollisionEnter(Collision collision) { GameObject particle; if (collision.gameObject.CompareTag("Stone")) { particle = PoolObject.GetObject(Globals.PoolKey.VFXStone); particle.transform.position = transform.position; } if (collision.gameObject.CompareTag("Metal")) { particle = PoolObject.GetObject(Globals.PoolKey.VFXMetal); particle.transform.position = transform.position; particle.transform.rotation = Quaternion.FromToRotation(Vector3.up, collision.contacts[0].normal);; } if (collision.gameObject.CompareTag("Ground")) { particle = PoolObject.GetObject(Globals.PoolKey.VFXSend); particle.transform.position = transform.position; } if (collision.gameObject.CompareTag("Glass")) { TriangleExplosion explosion = collision.gameObject.GetComponent <TriangleExplosion>(); explosion.StartCoroutine(explosion.SplitMesh(false)); } StopCoroutine(BulletLifeTime()); gameObject.SetActive(false); }
private IEnumerator TimerShot() { yield return(new WaitForSeconds(delayShot)); if (target != null) { var bullet = bulletPool.GetObject(spawnPointBullet.position); bullet.InitBullet(target, bulletPool.ReturnObject); } StartCoroutine(TimerShot()); }
/// <summary> /// Called on FPSController /// </summary> public void Fire() { if (!m_canShot) { return; } m_canShot = false; GameObject currentBullet = PoolObject.GetObject(Globals.PoolKey.BulletGameObject) /*Instantiate(m_bulletPrefab, m_muzzle.position, m_muzzle.rotation)*/; if (currentBullet == null) { Debug.LogError("Bullet Doesent Found"); return; } currentBullet.transform.position = m_muzzle.transform.position; currentBullet.transform.rotation = m_muzzle.transform.rotation; m_aniamtor.SetTrigger("Shot"); //VFX GameObject VFXMuzzle = PoolObject.GetObject(Globals.PoolKey.VFXMuzzle); if (VFXMuzzle != null) { VFXMuzzle.transform.position = m_muzzle.transform.position; } GameObject VFXEjection = PoolObject.GetObject(Globals.PoolKey.VFXEjection, m_ejection.position, m_ejection.eulerAngles, false); if (VFXEjection != null) { VFXEjection.SetActive(true); } StartCoroutine(Reload()); }