Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / FAST BULLETS

Author
Message
heyworth83
23
Years of Service
User Offline
Joined: 26th Nov 2002
Location: United Kingdom
Posted: 19th Jun 2003 01:05
MOST FIRST PERSON SHOOTERS USE A SYSTEM WHERE A BULLET IMMEDIATELY COLLIDES ANY OBJECT IT COMES ACCROSS. EVEN AT THIS SPEED THE BULLET NEVER JUMPS PAST OBJECTS. TO EXPLAIN WHAT I MEAN CONSIDER THIS:
A 3D BULLET OBJECT MOVING IN STEPS OF SAY 100 COULD SKIP PAT AN OBJECT SMALLER THAN 100 UNITS. IS THERE ANY WAY OF MAKING SURE THAT A BULLET OF ANY SPEED WILL ALWAYS HIT THE FIRST(IF ANY) OBJECT IT ENCOUNTERS? THANKS. (P.S. I HAVE NO CODE TO EXPLAIN THIS BETTER SORRY).
GameKit
23
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 19th Jun 2003 02:34
hmmm... i know what you mean... i might have an idea what you could do... put this somewhere in your main loop...

for a=0 to [distance per loop] step [distance per loop / collision checks per loop]
move object [object number],[distance per loop / collision checks per loop]
...code to check for collision...
next a

this will check for collisions multiple times per loop... that way it has less of a chance of missing a smaller object... the smaller you make the [distance per loop / collision checks per loop] the more accurate it will be but it will be slower...well...i hope this helps...

Anyone Can Destroy...But Few Can Create...
Misanthrope
23
Years of Service
User Offline
Joined: 31st Jan 2003
Location:
Posted: 19th Jun 2003 02:56
You'd have to establish a collision envelope that stretches out across the entire length of movement during that step.

That is, if your bullet moves 100 units, you want an invisible collision envelope that's 100 units in length along the axis of movement, centered on the bullet itself. Do your collision checking off that envelope rather than the actual bullet itself, and it'll register collisions that otherwise would be missed.

A rotated collision box would do splendidly, as you are allowed to specify the dimensions of the box at creation. In this case, you would specify the box dimensions thusly:



The other objects in the environment should ideally use collision boxes as well, if only because it's much faster than the old collision routines.

Subsequently, if you call object hit(objBullet,0) each time you move the bullet, it should return the object number of whatever objBullet collided with.

-Misanthrope
Misanthrope
23
Years of Service
User Offline
Joined: 31st Jan 2003
Location:
Posted: 19th Jun 2003 03:05
You could (and probably should) also subtract and add half the object's Z-axis size to the collision envelope's MinZ# and MaxZ# variables, respectively, in the pseudocode I posted previously if you wanted to. I left that out for the sake of clarity.

-Misanthrope
heyworth83
23
Years of Service
User Offline
Joined: 26th Nov 2002
Location: United Kingdom
Posted: 20th Jun 2003 16:16
THATS GREAT THANKS EVERYONE.
Mike29936
23
Years of Service
User Offline
Joined: 19th Jun 2003
Location:
Posted: 20th Jun 2003 18:09 Edited at: 20th Jun 2003 18:14
You mind un-caps-locking your post? Not sure I know what you're talking about when you use caps lock.

From what I understand, you're having problems with the bullet going past the player since it's speed is 100, and the player's smaller.
My solution for this in 2D would be to have an 'xprevious' and 'yprevious', which is the previous spot the bullet was at. Then I would have some code something like this:

if objectx >= bulletx and objectx <= xprevious and objecty >= bullety and objecty <= yprevious then do stuff

I don't do 3D, but maybe you could add a 'zprevious' and 'objectz' in there, and that would fix the problem.

(edit)

Just realized this would only work if the bullet had a negative x/y/z speed, but you can add a check for sign.

hexGEAR
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 20th Jun 2003 20:23
what you need is a line of sight between the character that fires the bullet and the bullet, using object collision between the line of sight and the target object will determine if he was shot or not, only difficult thing would be determining the coordinates of collision

to live is to suffer, to survive, well, thats to find meaning in the sufferening.....
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 20th Jun 2003 21:27
if you are using Pro then try the intersect object command, otherwise I use elongated spheres, (1,30,1 ratio), and move them from one to five times per loop while checking for collision, if you ghost them and colour them with a lava like texture they look like machine gun tracer in flight.

Mentor.

Flashing Blade
23
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 20th Jun 2003 22:23 Edited at: 20th Jun 2003 22:24
Yes I find interxsect object good - heres an example:

Change bullit speed at line 76

Login to post a reply

Server time is: 2026-07-06 20:50:49
Your offset time is: 2026-07-06 20:50:49