I’m making an action platformer. I’m having the player shoot a shot gun with a spread shot like this (excuse the lack of drawing skills I can’t draw):
I’m using
Rigidbody2D.AddRelativeForce
But for some reason the bullets don’t move forward, they spawn but just sit there. Here’s a picture of the Rigidbody on each bullet. I do want to be adding local force, so they can seperateAnd finally here’s the relevant code from the player script:
void ShootWeapon()
{
for (float j = -bulletSpreadAngle; j < bulletSpreadAngle; j += bulletSpreadAngle / numOfBullets * 2)
{
GameObject bullet = Instantiate(bulletPrefab, gunEnd.position, Quaternion.identity);
Rigidbody2D projectileRigidbody = bullet.GetComponent<Rigidbody2D>();
print(j);
bullet.transform.localRotation = new Quaternion(Quaternion.identity.x, Quaternion.identity.y, j, Quaternion.identity.w);
projectileRigidbody.AddRelativeForce(new Vector2(bulletSpeed, projectileRigidbody.velocity.y), ForceMode2D.Impulse);
}
}