Hitscan Shotgun: Multiple raycasts

Hi.
I’ve been working on my third person shooter and recently decided to change from firing trigger boxes to using raycasts. This works amazingly well for most of the in-game guns. It’s only with the shotgun, which casts multiple rays at once, that problems ensue.

I don’t know why, but only the first ray ever registers as a hit, while the others behave like a miss… I’m not sure why.

The shotgun’s code is rather messy, so to put things short, when the shotgun fires, the following

			RaycastHit hit;

Then, each fired pellet, the following block happens (only with different PelletSpawn-numbers)

					if (Physics.Raycast (PelletSpawn9.transform.position, PelletSpawn9.transform.forward, out hit)) {
						EnemyAI Enemy = hit.transform.GetComponent<EnemyAI> ();
						if (Enemy != null) {
							Enemy.TakeDamage (Damage);
							Instantiate (DamageEffect, hit.point, Quaternion.LookRotation(hit.normal));

						}
						if (Enemy == null) {

							Instantiate (MissEffect, hit.point, Quaternion.LookRotation(hit.normal));

						}
					}

Any ideas on what the problem might be?

It’s difficult to say from the code you’ve provided. Are you sure your the rays are generated where you want them to be? You can use Debug.DrawRay to see your rays in the scene view.