/// <summary> /// Fires a bullet /// </summary> public void Fire(int owner, Vector3 firePosition, Quaternion fireRotation) { GameObject obj = NewObjectPooler.Get().GetPooledObject(); if (obj == null) { Debug.LogError("Could not generate bullet from pooler"); return; } obj.transform.position = firePosition; obj.transform.rotation = fireRotation; obj.transform.Translate(SpawnOffset); obj.SetActive(true); obj.GetComponent <Bullet>().Owner = owner; Vector3 bulletVelocity = transform.right * m_bulletSpeedForward + Vector3.up * m_bulletSpeedUp; obj.GetComponent <Rigidbody>().AddForce(bulletVelocity); if (PlayerManager.IsCloseToPlayer(obj.transform.position, 30.0f)) { SoundManager.Get().PlaySound(SoundManager.SoundID.FIRE); } }
private bool m_willGrow = true; // Determines if more objects can be added to the poolwhen needed. #endregion Fields #region Methods /// <summary> /// Gets the Object pooler from the scene /// </summary> public static NewObjectPooler Get() { if(sm_objPooler == null) { sm_objPooler = FindObjectOfType<NewObjectPooler>(); if(sm_objPooler == null) { Debug.LogError("Could not find NewObjectPooler"); } } return sm_objPooler; }
/// <summary> /// Gets the Object pooler from the scene /// </summary> public static NewObjectPooler Get() { if (sm_objPooler == null) { sm_objPooler = FindObjectOfType <NewObjectPooler>(); if (sm_objPooler == null) { Debug.LogError("Could not find NewObjectPooler"); } } return(sm_objPooler); }
void Awake() { current = this; }
private void Awake() { Instance = this; }