Vector3 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
float angle = Mathf.Atan2 (mousePos.y - transform.position.y, mousePos.x - transform.position.x);
for (int i = 0; i < 5; i++) {
GameObject bu = Instantiate (bullet, transform.position, Quaternion.identity) as GameObject;
angle = Mathf.Atan2 (mousePos.y - transform.position.y, mousePos.x - transform.position.x) - Mathf.PI/2.0f+Mathf.PI*((float)i)/4.0f;
float xspeed = speed * Mathf.Cos (angle) * 1.5f;
float yspeed = speed * Mathf.Sin (angle) * 1.5f;
bu.GetComponent<Rigidbody2D> ().velocity = new Vector2 (xspeed, yspeed);
This is code snippet of my code used. I tend to get 5 lines of bullets while player fires(180 degrees between 1st and 5th line, and 45 degrees for near lines). It works well when my player remains static. However, when my player moves, the angle between 1st and 5th line shrinks for some reason (my bullets gets more concentrated). I checked the velocity of bullets, it is right. How does this situation happen? Is the motion of player affect the bullets?
Thank you!