I'm having troubles using a Capsule Cast

I’ve started to add different guns to my game, most recently a shot gun, up until recently I’ve been using raycasts to detect if I’m shooting something, which is fine for most guns, but I wanted the Shotgun to have more of a spread, so you don’t have to be as accurate, so I looked up how I could somehow widen a Raycast, I’ve found out about the Capsule Cast, which can do exactly what I wanted.

I’m having problems using it though, with some guns, it works great, but with others, the accuracy’s way off, way above or below the crosshair.

Here’s my code:

	shooting = true;
	RaycastHit hit;
	Vector3 directionRay = gunMuzzle.TransformDirection(Vector3.forward);
	//Vector3 capsulePoint2 = gunMuzzle.position + directionRay;
	Debug.DrawRay (gunMuzzle.position, directionRay * range, Color.red);
	if (bulletsLeft > 0 || isMeleeWeapon)
	if (Physics.SphereCast(gunMuzzle.position, spread, directionRay, out hit, range))
		if (hit.rigidbody)
			if (hitParticle)
				hitParticle.transform.position = hit.point;
				hitParticle.transform.localRotation = Quaternion.FromToRotation(Vector3.forward,
			hit.rigidbody.AddForceAtPosition(directionRay * force, hit.point);
			hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
				if (isMeleeWeapon)
		else if (hit.collider.gameObject.CompareTag("Kruncanite"))
				if (!bloodEffect)
					bloodEffect.transform.position = hit.point;
					bloodEffect.transform.localRotation = Quaternion.FromToRotation(Vector3.forward, hit.normal);

What am I doing wrong?

I use a sphere cast for my shotguns.

Its a sphere that starts at origin and then is cast forward like a thick ray.

The way you are using SpherCast/CapsuleCast - I don’t think it does what you think it does.

Both Sphere- and CapsuleCast will return only ONE hit, namely the first object they hit on their path. So using them for a multi-projectile weapon is NOT going to working.
There are two obvious alternatives:

Keep using RayCast, but cast many of them. Basically every pellet of a shotgun blast would be represented by one RayCast. Use the Random library to have each pellet follow a different path, thereby creating spread; the best implementation of this depends on the kind of game you are making (2D, 3D, arcade, realistic, …).

Use the SphereCastAll, which will return ALL possible hits. This solution will require the most work from you, as you will have to set up rules on how to handle different cases of objects and hit characteristics. For example, an object with many colliders would register more hits; similarly, you likely want a bigger object to receive more damage. It will also return hits that would have been blocked by other objects.