public static void Fire(Vector3 pos) { if (bulet == null) { bulet = Resources.Load <Bulet>(ResPath); } Instantiate <Bulet>(bulet, pos, Quaternion.identity); }
void Shoot() { GameObject bulletGO = (GameObject)Instantiate(bulletPrefab, firepoint.position, firepoint.rotation); Bulet bullet = bulletGO.GetComponent <Bulet>(); if (bullet != null) { bullet.Seek(this.target); } Debug.Log("Shooot!"); }
private void Update() { float h = Input.GetAxis("Horizontal"); if (h != 0) { t.Translate(new Vector3(h, 0, 0) * Time.deltaTime * Speed, Space.World); t.localEulerAngles = new Vector3(0, h * 30, 0); } else { t.localEulerAngles = new Vector3(0, 0, 0); } if (Input.GetAxis("Jump") != 0 && TimeGun <= 0) { Bulet.Fire(LeftGun.position); Bulet.Fire(RightGun.position); TimeGun = .25f; } TimeGun -= Time.deltaTime; }
private void RemoveElement(Bulet bulet) { _bulets.Remove(bulet); _movables.Remove(bulet); _destructibles.Remove(bulet); }
private void AddElement(Bulet bulet) { _bulets.Add(bulet); _movables.Add(bulet); _destructibles.Add(bulet); }