IEnumerator WaitAndHideObject() { yield return(new WaitForSeconds(1)); gameObject.SetActive(false); ShellPoolManager.AddObject(this); }
public void ShotShell(Sprite sprite, float speed, int damage, float shellReloadTime) { reloadTime = shellReloadTime; float angle = Mathf.Atan2(tankShellPoint.right.y, tankShellPoint.right.x) * Mathf.Rad2Deg; ShellBehaviour shell = ShellPoolManager.GetObject(); if (shell != null) { shell.transform.position = tankShellPoint.position; shell.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); shell.gameObject.SetActive(true); } else { shell = Instantiate(tankShell, tankShellPoint.position, Quaternion.AngleAxis(angle, Vector3.forward)) as ShellBehaviour; } shell.SetDirection(tankShellPoint.right, sprite, speed, damage); }