public class weapon : MonoBehaviour { public Transform firepoint1; //this is a firepoint public Transform firepoint2; //this is a firepoint public GameObject bulletprefab; public GameObject f; public GameObject f1; // Start is called before the first frame update void Start() { Rigidbody2D rb = GetComponent(); rb.constraints = RigidbodyConstraints2D.FreezeRotation; } // Update is called once per frame void Update() { } void shoot() { //shoot Instantiate(bulletprefab, firepoint1.position, firepoint1.rotation); } void shoot1() { Instantiate(bulletprefab, firepoint2.position, firepoint2.rotation); } void OnTriggerStay2D(Collider2D trig) { if (f.gameObject != null && gameObject.tag =="player") { if (Input.GetButtonDown("Fire1")) { shoot(); } } if (f.gameObject != null && gameObject.tag == "player") { if (Input.GetButtonDown("Fire1")) { shoot1(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)