Blast Radius

Hi guys, I have a series of weapons i am working on , and all of them are doing great , except my shotgun. I am trying to use a SphereCast to decide on if the target is within the blasts spray radius. It doesnt seem to work well though.

At distance, it works great, as in , max shotgun range , it seems to have the exact spray radius it should, but when you get up in an enemies face, you would expect that it would be easy pickings , and its exactly the oppisite. Seems the Spherecast completely misses the enemy when your in their face. Is there an easier way to do this , should spherecast not be used for this or …

I thought it would be perfect , but it doesnt seem to be doing the trick at all.

		if(Physics.SphereCast(transform.position, blastRadius, transform.forward, hit, range)){

I have asked about this sphere casting before actually and didnt get a single reply :(. Maybe someone can give a hand?

Closest thread i can find related to is this …

http://forum.unity3d.com/threads/83775-Creating-a-shotgun

and it doesnt really say how to use the OverlapSphere… im just not getting any decent results.

From my understanding, a spherecast is like a fat raycast - you are firing a sphere forward and detecting hits with it. I don’t think it would simulate a shotgun blast really well, as it doesn’t expand it’s radius as it goes.

You could use an OverlapSphere to get an array of Colliders within range. Then iterate through that array to see which are within the correct angle of your blast, maybe using Dot Product of the gun and the Collider transform.

OverlapSphere is easy to use; give it a position and radius and it returns an array of Colliders that are within that volume. You may also want to use layerMask to filter out Colliders that you are not interested in detecting.

Yea i figured out a work around using OverlapSphere, thanks m8.