Fastes pawn tracing method?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

SoSilencer

Harry Goz (1932 - 2003)
Nov 27, 2000
834
0
0
43
unrealdev.net
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.
 

SoSilencer

Harry Goz (1932 - 2003)
Nov 27, 2000
834
0
0
43
unrealdev.net
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.
 

usaar33

Un1337
Mar 25, 2000
808
0
0
Unknown
www.UsAaR33.com
From the Legacy RailRifle. This also goes through glass :p

Code:
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");  }
  Owner.MakeNoise(Pawn(Owner).SoundDampening);
  GetAxes(Pawn(owner).ViewRotation,X,Y,Z);
   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);  
  x=vector(adjustedaim);
  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.
    testdecal=spawn(class'legacy.testdecal',,,HitLocation+HitNormal*9,Rotator(HitNormal));
    if (testdecal.surfaceismasked()){      //this means that the rifle can go through
    testdecal.destroy();
    StartTrace = HitLocation + (57* X);   //move it up 57.
      EndTrace = StartTrace + (10000 * vector(AdjustedAim));
      }
      else{
      testdecal.destroy();
       break;} }
       if (!fasttrace(starttrace,starttrace+vect(1,0,0))) break; //prevents infinite iterators
  }
  ringeffect=none;
   r = Spawn(class'LeRailRifleRings',,, HitLocation+HitNormal*8,rotator(HitNormal));
  if ( r != None )
  {
    r.PlaySound(r.ExploSound,,6);
    r.DrawType = DT_None;
  }
  if (level.netmode==nm_standalone&&olddecal==false)
  owner.ConsoleCommand("set ini:Engine.Engine.ViewportManager Decals false");
}