How to make a spreading bullet like the ones in shmup games? I tried to duplicate and rotate the weapon, but it ends up shooting at the same direction. Here's my code. Code (CSharp): void Update () { if ((Input.GetAxisRaw("FireHorizontal") != 0.0f || Input.GetAxisRaw("FireVertical") != 0.0f) && canAttack) { Vector3 shootDirection = new Vector3(Input.GetAxis("FireHorizontal"), 0, Input.GetAxis("FireVertical")).normalized; GameObject bulletInstance = Instantiate(projectile, transform.position, Quaternion.LookRotation(shootDirection)) as GameObject; bulletInstance.GetComponent<Rigidbody>().AddForce(shootDirection * projectileSpeed, ForceMode.Impulse); canAttack = false; Invoke("ProjectileDelay", attackDelay); } } void ProjectileDelay() { canAttack = true; } Thanks.
Can you tell me how to set the rotation angle? It seems like everything i do that doesn't have squiggly lines just ends up shooting at the same direction. Thanks.
Again, I don't do it the most efficient way as angles do my head in. I have extra bullet spawn points that I set to the angle needed then when the player has the multi shot power up I instantiate bullets at each of them at the rotation of the spawn point/s. But.... I focus on 2d so I only have a 2d spread to worry about. The only time I didn't use multi spawn points was when my ship shot in the 4 compass points in which case I used the ships position + vector2.up, down, left, right & found the angles to use to get the 90° increments. I still used 4 instantiate lines tho.