Posted: 22nd Jun 2007 6:40
I'm using ray intersections to calculate bullet hits in my fps but im trying to find a way to make my weapons have varying amounts of accuracy ie smg would fire bullets every where while a sniper would hit the spot exactly. Anyone got any ideas...
Posted: 22nd Jun 2007 8:21
That is a problem with your use of raycasting, because SMGs spray primarily due to the fact that they lob smaller masses at reduced speed. Then, it gets worse due to the movement of the barrel.

So, you can do one of several things:
You can slightly offset the origin of the bullets.
You can offset the endpoint by a small amount.
You could add a small angle to that of the barrel.

Personally, I would opt for option 3, since it simulates the barrel moving, and you could just make it worse the longer the trigger is held.
Posted: 23rd Jun 2007 4:11
Cool anyone else got some ideas
Posted: 23rd Jun 2007 5:10
Yeah, you just want to move your ray around more for unaccurate weapons. I agree that turning it by an angle would be the best option, but moving the endpoint would be just as good since its pretty much the same thing. The only problem is that, depending on the length of your ray, you would have to move it by different ammounts to get a consistent amount of accuracy for the same weapon. Longer Ray + More Endpoint Shift = Same Accuracy.
Posted: 23rd Jun 2007 8:41
Cool how would i handle weapons that spray out ie shot gun for example would i need to cast more rays or check if objects are within a distance of ray object?
Posted: 25th Jun 2007 1:29
For a weapon like a shotgun, i would check a whole bunch of rays, and you could just move the endpoints / change the angle randomly on each one.