- Home /
Question by
The_Architekt · Apr 22 at 10:41 AM ·
2d gamebullettop down shooterspread
How to do bullet spread in 2D?
I need help with bullet spread in a top down 2d game
My current code, located in a script that recieves an input from the player is:
void Shoot()
{
Quaternion spread = firePoint.rotation * Quaternion.Euler(0,0, Random.Range(-100f, 101f)); GameObject bullet = Instantiate(bulletPrefab, firePoint.position, spread);
Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>();
rb.AddForce(transform.up * bulletForce, ForceMode2D.Impulse);
}
However, this does not seem to have any effect
Any idea why?
Comment
Best Answer
Answer by ArmanDoesStuff · Apr 22 at 02:38 PM
Don't you want to be adding the forcing in the bullet.transform.up direction rather than just transform.up?
Your answer
Follow this Question
Related Questions
Enemies in top down shooter being affected by physics of bullet 1 Answer
Need some help with bullets spread fire!!! 1 Answer
I need help with a top down 2d shooter 3 Answers
How to make a bullet spread 1 Answer
2D top down shooter border. 1 Answer