So i have this script where i rotate the instantiated bullet to the players rotation so it is rotated the right direction, and then add force to the bullet in its own rotation, then i also add some recoil or bulletspread on the y axis on the rotation. But when i move and rotate the player the bullet goes in random directions. I think the problem is in the w parameter in the rotation of the bullet. I do not quite know what its for. If i set it to 0 there is not bulletspread and the bullet only goes one direction. Any help is welcome!
nextFire = Time.time + fireRate;
//spawn bullet
ammo--;
GameObject spawnedBullet2 = Instantiate (bulletPrefab) as GameObject;
spawnedBullet2.GetComponent<Laser> ().laserDamage = damage;
spawnedBullet2.transform.position = spawnPos.transform.position;
Rigidbody rb1 = spawnedBullet2.GetComponent<Rigidbody> ();
Quaternion rot = new Quaternion(transform.rotation.x, spawnPos.transform.rotation.y + Random.Range (-recoil, recoil), spawnPos.transform.rotation.z, 2);
spawnedBullet2.transform.rotation = rot;
rb1.AddForce (spawnedBullet2.transform.forward * 1000);