Advertisement

Shooters

Started by February 28, 2003 02:10 PM
2 comments, last by cowsarenotevil 22 years ago
How do games like quake check to see if someone has been shot? Do they use picking, or do they move the bullet a bit and check each frame. If so, how do they avoid having the bullet skip over people?
-~-The Cow of Darkness-~-
It depends on the weapon design.

Some weapons travel their distance instantly, so they cast a ray forward and see if it strikes any geometry represented by a player. The first thing collided with is what absorbs the bullet and takes damage. The chain gun and rail gun from Quake 2 are good examples of this (even though the rail gun still had a graphic effect that lasted for a second or so after the damage was dealt)

Travelling weaponry (missiles, plasma balls, etc.) will check for a collision each game tick. To avoid passing through objects from one frame to the next, the previous position and current position are used to make a line segment. That line segment is then checked for collisions against the nearby objects. Again, the first object to collide with the segment takes the damage.

Sometimes, two objects are travelling so fast, they both are turned into segments and checked for a collision along their paths. That calculation is a little more intensive, but also works. Something like this might apply for a slow travelling missile intercepting a player running perpendicular to its path.

The collision detection for the weapon is a little more complex than a simple line segment for weapons that actually have a radius to them, but hopefully you get the idea.


[edited by - Waverider on February 28, 2003 3:23:41 PM]

[edited by - Waverider on February 28, 2003 3:24:49 PM]
It's not what you're taught, it's what you learn.
Advertisement
usually a simple partle engine is used to manage the bullets. the are updated everyframe. by updated I mean their velocity is added to its position and drawn in the next frame. usually people use bounding sphere collision detection. that would be the easiest and probably most practical way to see if the bullet has hit an object. there are, of course, many other types of collision detection more sophisticated.
hope that helps some,
Joe

My Homepage
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
If you decide to use the technique thet Julio described, with updating it each frame, you could also use ellipsoid collision. Although I doubt that it would be necessary for bullets, because spheres would give enough precision, in that case.

(Cows are evil in Diablo 2 )

[EDIT: corrected spelling]

[edited by - James Trotter on February 28, 2003 5:32:47 PM]

This topic is closed to new replies.

Advertisement