So basically, my game is a platformer where the gun is aiming towards the mouse, kinda like Karlson 2D. I’m trying to do a shotgun spread, but what I have for the bullet spread so far is this -
` if (timeBtwShots <= 0)
{
if (Input.GetMouseButton(0) && CurrentAmmo>0)
{
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(projectile, firePoint.position, Quaternion.Euler(0, 0, Random.Range(MinSpread, MaxSpread)));
Instantiate(boomEffect, boomPoint.position, boomPoint.rotation);
timeBtwShots = startTimeBtwShots;
CurrentAmmo--;
}
}
Whenever I fire, the firing path is locked right. Even if the gun is pointed left or I’m facing left, the bullets fly left. What would be a way to fix this?
Also, is there a way to make the code less… messy? I have 10 instantiates, is there a way I can repeatedly instantiate?
`