Posted: 24th Jun 2007 10:33
What is that best way to calculate if an enemy is hit by the spray of an shot gun blast im using ray casting at the moment for the other weapons but i think there might be a better way.
Posted: 24th Jun 2007 11:56
You can do several things.

If slight performance fluctuations are no issue, you can simple cast a few multiple rays to imitate a blast. But don't try, say, 30 - raycasting is pretty slow and doing that will slow you game to a crawl.

You can also just emit a spray of objects and do it projectile style.

My thought on the best method (I've never actually tried this, I'm just throwing this out there) is to make a triangle object with one vertex at the end of the barrel, and then position the other two vertices so that the triange forms a fan shape imitating the weapon's spray. Then, hide the object and check for collision with enemies when you fire, deceasing the damage the father away the enemy is. It would probably be very fast. Let me know if I'm being confusing.

If you're really in to it, you could also make a whole pyramid imitating the range of the shotgun's blast, so that enemies above and below would also be affected by the spray.

-ThinkDigital
Posted: 24th Jun 2007 12:14
Sounds like a plan ill look into the pyramid type thing.
Posted: 24th Jun 2007 12:41
A little project of mine has newton doing about 4 million raycasts a second -- quite happily.
When syncing the screen as fast as possible (about 540 fps) it still does about 50k raycasts (100 raycasts each frame). It could be that these are really short raycasts, but I always thought raycasting was fast.
Posted: 24th Jun 2007 13:18
Hmm. Odd. I use Sparky, and I can never fit in more than about a dozen raycasts a loop without slowing it down to a painfully slow speed Besides, seems to me that raycasting would be a pain to calculate - I seem to remember reading it was generally slow...

*shrug*
Posted: 27th Jun 2007 1:47
Well i used an object which works except how do I stop it from shooting through walls and objects etc but still hit the enemys where appropriate.
Posted: 27th Jun 2007 1:51
I use Sparky, and I can never fit in more than about a dozen raycasts a loop without slowing it down to a painfully slow speed


You must be doing something wrong. Sparky's collision system and ray casting in general is usually very fast and efficient.
Posted: 27th Jun 2007 3:50
I'm thinkning about your original spray weapon how to question and the pyramid suggestion... I would do som,ething effectivle similiar (but different)

The important thing to me in that equation if I was trying to get fancy would be making the damage based on how close and how much blast the "target " actually got hit by. Up close and personal? Likely painful. Second floor on a platform, grazed from a feww bb's from a guy halfway across the warehouse - perhaps a decent sting - "Ow you son of a %$@%$@3" wihout loss of health perhaps.

The pyramid would (if I'm understanding the idea) work execellnt providing distance was in the equation also. This - for me - would count - as simply touching the pyramid might be a little demanding for the poor guy on the wrong side of the gun - a bit harsh.

Naturally the ray casting thing seems rather decent for the spread - allowing for the occasional "miss" because shotgun pellets went over and under someones arm but the arm was luckiliy missed because of how far away from gun etc.

I'm just visiting the forums and chatting...

Have fun and I hope to hear how this turns out.

Best REgards,
Jason P Sage
Posted: 27th Jun 2007 7:11
Raycasting is ideal because each pellet has its own trajectory and path. You'd only send the rays once, so it wouldn't affect game speed. It's not like you'd have an automatic shotgun or something.

Sparky's is very fast. If you really wanted to, you could spread the raycasts over a number of loops. If you wanted 30 raycasts you could divide it over 3 program loops, doing 10 each time.

So, what happened to your RPG? Why are you working on an FPS instead?
Posted: 27th Jun 2007 10:43
In Lonewolf (old FPS project) I used raycasting for all the bullet collisions, for the shotgun I just interfered with the bullets, like with the sniper rifle the bullet would be sent on the exact path and would be flagged with a high damage value, so usually 1 hit would do it with a sniper rifle. With the shotgun, I used 8 seperate bullets, each with some interference on the trajectory and I fire them all at the same time with maybe 1/5th the damage of a sniper bullet.

This means that it behaves just like a shotgun because to kill the enemy with 1 shot you'd have to get pretty close so that each bullet hits the enemy, the further you are away, the more likely you are that some bullets will miss. With the trajectory interference you get a spread effect, and a kinda natural behavior to your shotty. To add interference, I'd just add a random value to each axis of the destination of the bullet.
Posted: 28th Jun 2007 1:33
Im still working on the rpg this is more of a personal side project that i do in my spare time.