Page 1 of 1

Traceline speed

Posted: Sun Dec 23, 2012 2:11 am
by Mexicouger
Is it possible to control the speed of a traceline? Or are they instant point a, to point b?

Re: Traceline speed

Posted: Sun Dec 23, 2012 3:04 am
by Spike
just look at the builtin definition. if you did, you'd realise that there's no way to specify a velocity/speed/time/etc.

Re: Traceline speed

Posted: Sun Dec 23, 2012 3:12 am
by Mexicouger
Thanks. I was just making sure

Re: Traceline speed

Posted: Sun Dec 23, 2012 3:25 am
by gnounc
you could always trace after a delay to imitate bullet travel speed

Re: Traceline speed

Posted: Sun Dec 23, 2012 4:14 am
by taniwha
Traceline is instant: it has to be because it's used (internally, but indirectly*) for collision detection of moving objects.

The way traceline is used is to do a trace for the distance the object will move in one frame. There is no speed limit in quake's physics**, so if you want to have a non-instant but very fast bullet, just set the bullet's speed to something appropriate and let the physics engine take care of everything (cloning the nail code is a good start).

The reason traceline is used for collision detection is to avoid the issue of a fast moving object missing just because its per-frame position never hits the target. Unfortunately, quake does not do it both ways, so two fast moving objects will miss even when they shouldn't, but for one fast and one slow (or both slow), it will work.

* Actually, traceline isn't used, but rather the code for which traceline is a wrapper is used, so it's effectively the same thing.

** Mostly. There is one, but it's caused by the precision of floats so it's pretty high.

Re: Traceline speed

Posted: Sun Dec 23, 2012 4:42 am
by taniwha
BTW, it is possible to get the quake engine to handle collision between very fast objects, but it would take engine hacking and may not be worth the trouble (it might be too expensive):
  1. Create hulls representing the paths of traced by all moving objects for the current frame (ie, the hull for a moving object represents the path it traces in this frame). This hull would be clipped against the world.
  2. Test each pair of hulls for mutual intersection and for each intersection, find the times of "impact" of the two objects owning the hulls. There wil actually be two times for each object: the time where the first object first touches the second object's trace-hull, and the time where the first object last touches the second object's trace-hull.
  3. If the "impact" time spans overlap, then the objects collide, otherwise they miss. It should be possible to play with the time spans (along with other available information) to get the exact time of impact.
Part of the expense would come from collisions affecting other collisions. For three objects, A, B and C, all moving, both B and C might be on collision courses with A, but B colliding with A might prevent C from colling with A because A didn't reach the A-C collision. One way to handle it is to calculate the times for all intersecting pairs, sort the pairs by time, then work through each pair from earlies to latest.

Re: Traceline speed

Posted: Sun Dec 23, 2012 7:58 pm
by ceriux
once someone gave me some qc that made the nail gun work off of traces lines. maybe you could spawn a null entity and have the trace follow the front of it instead?