View Full Version : Fastes pawn tracing method?

13th Nov 2001, 12:28 AM
I've created a laser gun similar to the quake railguns that appears as one solid line along with a varying amount of particles and stuff to make each players shot look unique. I got the beam to appear properly (no gaps where players are, stuff like that) but can't decide on the best way to do the hit detection. What I'm doing now is...

local pawn Q;

foreach TraceActors(class'Pawn', Q, HitLoc, HitNorm, EndLoc, (Location - (122 * vector(rotation))), vect(8,8,8))
log("laser has hit: " $ Q);

The problem is that returns EVERYTHING, not just pawns like it's supposed to(?). It works but I'm worried that it would be slow like that because I call the function which does damage every tick until the beam fades out. I can't really think of any other simple ways of doing it though. Anyone have any suggestions?

While we're on the subject anyone have any suggestions for ways to make the beam look cool? You can pick from 7 different colors and can change the color of the beam and particles that spawn. You can select how often along the beam the particles spawn, how big they are, how fast they move, and how much they "jitter" when they move. It looks really neat but more is always better as long as it doesn't take too many cpu cycles or cause fps drops.

13th Nov 2001, 12:37 AM
I've also noticed that using that method seems to "miss" a lot. The trace never ever hits below a players waist, and many times it hits even if the shot is more than a foot over their head. I can compensate a little by using a larger extent box but that is hardly the ideal solution so maybe you have ideas on that too.

13th Nov 2001, 02:40 AM
From the Legacy RailRifle. This also goes through glass :p

function TraceFire( float Accuracy )
local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z;
local actor Other;
local testdecal testdecal;
local RingExplosion r;
local bool olddecal;
local bool bwalltrans;
local testdecal temp;

if (level.netmode==nm_standalone){ //force decals (for checks)
olddecal=bool(owner.ConsoleCommand("get ini:Engine.Engine.ViewportManager Decals"));
if (olddecal==false)
owner.ConsoleCommand("set ini:Engine.Engine.ViewportManager Decals true"); }
StartTrace = Owner.Location + Pawn(Owner).Eyeheight * Z; //based on sniper rifle, so the freaking crosshair is aligned!
AdjustedAim = pawn(owner).AdjustAim(1000000, StartTrace, 2.75*AimError, False, False);
EndTrace = (starttrace) + 10000 * X; //beam however, appears to leave gun.
while(true) {
Other = Pawn(Owner).TraceShot(HitLocation,HitNormal,EndTrace,StartTrace);
//if (other == none || other==level || pawn(owner).LineOfSightTo(other)) //this ensures that fog didn't screw up the system.
ProcessTraceHit(Other, HitLocation, HitNormal, vector(AdjustedAim), Y, Z);
if (other==none) break; //firing inside level or too far...
if( Other != Level )
StartTrace = HitLocation + HitNormal + (2*other.collisionradius * X);
EndTrace = StartTrace + (10000 * vector(AdjustedAim));
else{ //check for texture being masked.
if (testdecal.surfaceismasked()){ //this means that the rifle can go through
StartTrace = HitLocation + (57* X); //move it up 57.
EndTrace = StartTrace + (10000 * vector(AdjustedAim));
break;} }
if (!fasttrace(starttrace,starttrace+vect(1,0,0))) break; //prevents infinite iterators
r = Spawn(class'LeRailRifleRings',,, HitLocation+HitNormal*8,rotator(HitNormal));
if ( r != None )
r.DrawType = DT_None;
if (level.netmode==nm_standalone&&olddecal==false)
owner.ConsoleCommand("set ini:Engine.Engine.ViewportManager Decals false");