The easiest way to do this is to turn bullets into projectiles. In HL2 they are a single raycast. But in your mod you could decide how fast they travel and sweep a ray over each tick from the previous position to the current position of the projectile. You could add gravity easily enough. This will still approximate the motion in each tick with a line, but you could subdivide further if you really need more curvature. If the linear speed is high enough compared to gravity or the tick rate is high enough there won't be much error with one segment per tick.
// simplest per-frame integration function Vector newPosition = oldPosition + velocity * dt; Velocity += gravity * dt; UTIL_TraceLine( oldPosition, newPosition, ... Or you could even use vphysics objects if you want to spend a bit more memory & CPU on each bullet. > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Daniel Menard > Sent: Monday, January 03, 2005 8:17 PM > To: [email protected] > Subject: Re: [hlcoders] Objects, Physics, and Gravity Concepts > > Not that I'm personally facing this problem, but wouldnt you > be able to do a simple distance check and have the hitscan > move down depending on how far it traveled and the gravity. > The only problem I could see with this is that hitscan is a > line and it would actually modify the trajectory of the > bullet out of the barrel but there must be some way around > it. Just providing a few suggestions. If you can't fix the > bug, you might still have something relativly convincing... > > > On Mon, 3 Jan 2005 15:19:37 -0500, r00t 3:16 > <[EMAIL PROTECTED]> wrote: > > Thanks botman I will probably get this book :P > > > > > > r00t 3:16 > > CQC Gaming > > www.cqc-gaming.com > > > > ----- Original Message ----- > > From: "Jeffrey "botman" Broome" <[EMAIL PROTECTED]> > > To: <[email protected]> > > Sent: Monday, January 03, 2005 3:04 PM > > Subject: Re: [hlcoders] Objects, Physics, and Gravity Concepts > > > > > r00t 3:16 wrote: > > >> > > >> But suppose you wanted it so players who shoot weapons had to > > >> compensate for distance, aiming a little ahead of a > running player > > >> etc. > > >> > > >> Is the source engine able to do this? > > > > > > I think it probably depends on how fast you want the > bullets to move > > > through the air. > > > > > > If you make bullets a true entity (with gravity and collisions, > > > etc), then you have to update their location as they move through > > > the world (applying gravity, checking for collisions, etc.). > > > > > > Calculating the height change due to gravity over a given > period of > > > time is pretty straight forward high school physics (use > google.com > > > if you want the math). > > > > > > The real issue is that things that move VERY fast through > the world > > > don't get their position updated often enough to follow > the path of > > > a true parabola. You get something like this (excuse the > ASCII graphics)... > > > > > > Game Ticks (StartFrame) at the 'v's > > > > > > > > > v v v v > > > > > > x----------x > > > / \ > > > / \ > > > / \ > > > / \ > > > / \ > > > / \ > > > / \ > > > x x > > > > > > > > > The 'x' object follows the path of a parabola but because you are > > > not ticking the engine at 1000's of times per second, you wind up > > > with discrete locations along the curve (at the points in > time where > > > you can calculate where the entity will be at that time). If you > > > are only checking for collisions at these points in time > (or doing > > > line/hull checks from the previous point in time to the current > > > point in time), you will miss hitting entities that don't > lie along > > > your discrete path (like at the top of the arch in this case). > > > > > > You can modify the calculations so that you do your own "stepping" > > > between discrete points in time to create a true > parabolic curve and > > > do your own collision checking to see if an entity was collided > > > with, but this can be somewhat time/CPU consuming. > > > > > > There's a pretty good O'Reilly book called "Physics for Game > > > Developers"... > > > > > > http://www.oreilly.com/catalog/physicsgame/ > > > > > > ...if you are really serious about creating realistic physics in > > > games, you should definitely get that book (I hope your > math skills > > > are REALLY strong). :) > > > > > > -- > > > Jeffrey "botman" Broome > > > > > > _______________________________________________ > > > To unsubscribe, edit your list preferences, or view the list > > > archives, please visit: > > > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > > > > > > > > > > > > _______________________________________________ > > To unsubscribe, edit your list preferences, or view the > list archives, please visit: > > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > > > > > _______________________________________________ > To unsubscribe, edit your list preferences, or view the list > archives, please visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > > _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

