/* Provides a trace for the third-person camera. Outputs: Returns the actor hit or None. HitLocation is the location hit. HitNormal is the normal of the surface hit. Inputs: CharacterAttachmentLocation is the start point of the trace. Range is the maximum range to trace out to. */ simulated function Actor WeaponTrace(out vector HitLocation, out vector HitNormal, vector CharacterAttachmentLocation, float Range) { //The start and end points. 'C' is the camera's trace, and 'P' is the character's trace. local vector StartC, EndC, StartP, EndP; //The rotation axes local vector Xc, Yc, Zc, Xp, Yp, Zp; //The hit locations and normals local vector HitLocC, HitNormC, HitLocP, HitNormP; //The hit actors local actor hitC, hitP; //Get the axes in regard to rotation. GetAxes(trueCameraRotation, Xc, Yc, Zc); GetAxes(Rotation, Xp, Yp, Zp); //Calculate the start points //Start just off the camera in the forward direction...fixes problems with collisions StartC = trueCameraLocation + Xc * 250.0f; StartP = CharacterAttachmentLocation; //Calculate the end points EndC = StartC + Xc * Range; EndP = StartP + Xp * Range; //Trace for the camera hitC = Trace(HitLocC, HitNormC, EndC, StartC, true); if (hitC != None) //If the camera hit nothing, run a normal trace off for the character...at infinity, the points are the same hitP = Trace(HitLocP, HitNormP, HitLocC, StartP, true); else //If the camera hit something, we adjust the end point for that target. This trace is used to verify we cannot fire though objects hitP = Trace(HitLocP, HitNormP, EndC, StartP, true); if (hitP == None) //If the character hit nothing { if (hitC != None) //If the camera hit something HitLocation = HitLocC; //We hit where the camera hit else HitLocation = EndC; //We hit nothing, so set the hit point to infinity for graphical effects HitNormal = HitNormC; //We only care about the normal from the camera return hitC; } else if (hitP == hitC) //Both hit the same thing...doesn't matter which we return { HitLocation = HitLocC; HitNormal = HitNormP; return hitC; } else //They hit different objects, the character's take priority { HitLocation = HitLocP; HitNormal = HitNormP; return hitP; } }