#Ship fires from one point instead of both

1 messages · Page 1 of 1 (latest)

sour owl
#

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);'''
half parcelBOT
#

Use codeblocks to send code in a message!

To make a codeblock, surround your code with ```
To use C# syntax highlighting add cs after the three back ticks.

For example:
```cs
Console.WriteLine("Hello World");
```

Produces:

Console.WriteLine("Hello World");

To send lengthy code, paste it into https://paste.myst.rs/ and send the link of the paste into chat.