PDA

View Full Version : Tracing Extent


SoSilencer
22nd Sep 2001, 02:11 AM
Since the UT code for locking onto target is very unorganized and complicated (IMO of course) I've decided to simply write my own code from scratch. This will properly lock onto a valid target but it also locks onto anything else like the ground or a wall.

GetAxes(Pawn(Owner).ViewRotation, X, Y, Z);

StartTraceLoc = Location + (512 * X);
EndTraceLoc = Location + (4096 * X);
ExtentVect = vect(128,128,128);

NewTarget = Trace(HitLocation, HitNormal, EndTraceLoc, StartTraceLoc, true, ExtentVect);

Is there any way to tell that that function to only hit pawns of some sort? If not is there another function I could use that would do something similar? The weapon is pretty long range so using a regular trace is out of the question, you would never be able to keep your crosshair on a player model at 7500+ units. Using angles (I think this is how the UT eightball does it) is a less than perfect solution as well because in order to keep the overal radius of the targeting cone small enough at maximum range the angle would have to be extremely small, requiring you to keep your target on the player mesh at medium range instead.

However the extent trace above makes a nice 128 radius cylinder from me to the target meaning that at any range it is possible to lockon without the problem of having to be directly on target at certain ranges. Does anyone know of anything I could do that would only return pawns but act similiar to the "trace cylinder" of the extent trace I used above?

SoSilencer
22nd Sep 2001, 04:52 AM
Here is an update of the code I'm working with now.

EndTraceLoc = 4096 * Vector(Pawn(Owner).Rotation);

bTraceHa**** = False;

foreach TraceActors(Class'Pawn', NewTarget, HitLocation, HitNormal, EndTraceLoc, Location, vect(256,256,256))
{
Log("UTAnime: Iteration of TraceActors");
Log(NewTarget);

if ( (bTraceHa**** == False) && (NewTarget.IsA('Pawn')) && (NewTarget != Pawn(Owner)) )
{ rest of the code in this if statement

Now this is the weird part. if I open the log I get this...

ScriptLog: UTAnime: Iteration of TraceActors
ScriptLog: CTF-Face.LevelInfo0

That happens with both the start/end trace settings above and the trace start/end settings from the original post. I'm not sure why I'd be hitting the level info, especially because there is no level info in the level itself, so I'm kinda confused as to what I'm hitting and where, and why it's not going through all the pawns along the trace route like the docs say it should. It's about 5am now so I'm not thinking all that clear anymore but if that makes sense and you know what's wrong please let me know.

Wormbo
30th Dec 2001, 03:14 PM
I'm gonna bump all these old things to get my post count up. :D;):p

A LevelInfo actor is inside every Unreal level. It is hidden in the editor, but it is there.
Now, when a trace hits a wall it can't return that wall unless it is a mover, so it returns the LevelInfo. Look at the Trace() function's declaration in the Actor class:
// Trace a line and see what it collides with first.
// Takes this actor's collision properties into account.
// Returns first hit actor, Level if hit level, or None if hit nothing.
//
native(277) final function Actor Trace
(
out vector HitLocation,
out vector HitNormal,
vector TraceEnd,
optional vector TraceStart,
optional bool bTraceActors,
optional vector Extent
);
"Returns ... Level if hit level [geometry] ..."
If you check (NewTarget == Level) you will get "True" and if you look closer at the Actor class you will find
var const LevelInfo Level; // Level this actor is on.

The Level variable you access in code like "Level.Game.<something>" is actually a reference to the LevelInfo actor of the current map.

Call me Erdrik
19th Jan 2002, 01:12 PM
Originally posted by SoSilencer

....
GetAxes(Pawn(Owner).ViewRotation, X, Y, Z);

StartTraceLoc = Location + (512 * X);
EndTraceLoc = Location + (4096 * X);
ExtentVect = vect(128,128,128);

NewTarget = Trace(HitLocation, HitNormal, EndTraceLoc, StartTraceLoc, true, ExtentVect);

....


I don't know if you fixed already but:


TempTarget = Trace(HitLocation, HitNormal, EndTraceLoc, StartTraceLoc, true, ExtentVect);
NewTarget = Pawn(TempTarget);

I don't have Ued up right now but Im pretty sure
'NewTarget = Pawn(TempTarget);' will only return Pawns ....