I made a 2D version of a space ship
(PLACE HOLDER)
and on the tip of both wings I am trying make it fire phasers for both at the tip of the firepoint
Here is my code AKA Brackeys code from one of his great videos. In the video he his making it so a 2d soldier is shooting from a laser I thought it would work if I named the phasers fire point 1 and 2 and then double up on the code but it looked really messy to me so I decided to try a couple of other solutions but could not figure it out
'''public Transform firePoint;
public GameObject phaserPrefab;
public float phaserForce = 20f;
void Update()
{
if(Input.GetButtonDown("Fire1"))
{
Shoot();
}
}
void Shoot()
{
GameObject phaser = Instantiate(phaserPrefab, firePoint.position,firePoint.rotation);
Rigidbody2D rb = phaser.GetComponent<Rigidbody2D>();
rb.AddForce(firePoint.up * phaserForce, ForceMode2D.Impulse);'''