PDA

View Full Version : Still not clear about traces


WheatPuppet
1st Mar 2002, 02:49 PM
GetAxes(Pawn(owner).ViewRotation,X,Y,Z); // find the direction the player is looking
StartTrace = Owner.Location + CalcDrawOffset() + FireOffset.Y * Y + FireOffset.Z * Z; // the vector that the trace starts
EndTrace = StartTrace + Accuracy * (FRand() - 0.5 )* Y * 1000 + Accuracy * (FRand() - 0.5 ) * Z * 1000 ; //how does this get the place where the trace ends?


Please explain how EndTrace is actually found.
Thanks.

WheatPuppet
1st Mar 2002, 07:59 PM
Here we go! Explain this.


function TraceFire( float Accuracy )
{
local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z;
local actor Other;

Owner.MakeNoise(Pawn(Owner).SoundDampening);
GetAxes(Pawn(owner).ViewRotation,X,Y,Z); //okay, this gives the vectors x, y, and z the player's rotation, pitch, yaw, whatever. I got that.
StartTrace = Owner.Location + CalcDrawOffset() + FireOffset.Y * Y + FireOffset.Z * Z; //this places the beginning of the trace at Owner.Location plus the fire offset and the draw offset. This is where it gets a bit fuzzy.
/* Okay, a vector is a struct, right? A struct with three variables, x, y, and z. I am assuming that Owner.Location is also a vector. In the above statement I see the offsets (I understand those) being added to the Owner.Location, but I don't see how you can add the Y value to the Z value and get anything other than garbage numbers. Am I missing something?
Dammit! Must get off phone lines. Be back later with mucho edits.
Have at the rest of this.
*/
EndTrace = StartTrace + Accuracy * (FRand() - 0.5 )* Y * 1000
+ Accuracy * (FRand() - 0.5 ) * Z * 1000 ;

if ( bBotSpecialMove && (Tracked != None)
&& (((Owner.Acceleration == vect(0,0,0)) && (VSize(Owner.Velocity) < 40)) ||
(Normal(Owner.Velocity) Dot Normal(Tracked.Velocity) > 0.95)) )
EndTrace += 10000 * Normal(Tracked.Location - StartTrace);
else
{
AdjustedAim = pawn(owner).AdjustAim(1000000, StartTrace, 2.75*AimError, False, False);
EndTrace += (10000 * vector(AdjustedAim));
}

Tracked = None;
bBotSpecialMove = false;

Other = Pawn(Owner).TraceShot(HitLocation,HitNormal,EndTrace,StartTrace);
ProcessTraceHit(Other, HitLocation, HitNormal, vector(AdjustedAim),Y,Z);
}

Wormbo
2nd Mar 2002, 06:39 AM
if ( bBotSpecialMove && (Tracked != None)
&& (((Owner.Acceleration == vect(0,0,0)) && (VSize(Owner.Velocity) < 40)) ||
(Normal(Owner.Velocity) Dot Normal(Tracked.Velocity) > 0.95)) )
EndTrace += 10000 * Normal(Tracked.Location - StartTrace);
else
{
AdjustedAim = pawn(owner).AdjustAim(1000000, StartTrace, 2.75*AimError, False, False);
EndTrace += (10000 * vector(AdjustedAim));
}

AdjustedAim is a rotator with about the same (but not identical) direction as ViewRotation. Vector(AdjustedAim) has about the same direction as X and a length of 1. One of these two "EndTrace += ..." statements is always executed after "EndTrace = StartTrace + Accuracy * (FRand() - 0.5 )* Y * 1000 + Accuracy * (FRand() - 0.5 ) * Z * 1000;"

WheatPuppet
2nd Mar 2002, 03:29 PM
Originally posted by Wormbo


AdjustedAim is a rotator with about the same (but not identical) direction as ViewRotation. Vector(AdjustedAim) has about the same direction as X and a length of 1. One of these two "EndTrace += ..." statements is always executed after "EndTrace = StartTrace + Accuracy * (FRand() - 0.5 )* Y * 1000 + Accuracy * (FRand() - 0.5 ) * Z * 1000;"

Okay, is this right?
X = forward/back
Y = left/right
Z = up/down

I understand that one of those two things gets accessed after "EndTrace = StartTrace + Accuracy * (FRand() - 0.5 )* Y * 1000 + Accuracy * (FRand() - 0.5 ) * Z * 1000;", but how is it that the vector X, Y, and Z are each given their appropriate values?

I really feel thick-headed about this. Maybe I should make a big traceing stick to beat myself with.

Oh, BTW Wormbo, I am thoroughly addicted to your RocketsUT mutator.

EasyRaider
3rd Mar 2002, 06:19 AM
X, Y and Z are set in GetAxes().

And in case you have missed it, the actual tracing is done in Pawn.TraceShot().

WheatPuppet
4th Mar 2002, 09:32 AM
Originally posted by EasyrideR_/\
X, Y and Z are set in GetAxes().

And in case you have missed it, the actual tracing is done in Pawn.TraceShot().

I got the first part, but where is TraceShot() called?

What about this:

//vector struct
struct Vector
{
var x, y, z;
};
local Vector EndTrace, StartTrace;

EndTrace = StartTrace + Accuracy * (FRand() - 0.5 )* Y * 1000 + Accuracy * (FRand() - 0.5 ) * Z * 1000;
//
//okay endtrace = starttrace + accuracy * whatever...
//does this mean that endtrace = (starttrace.x+accuracy * whatever...; starttrace.y+accuracy * whatever...; starttrace.z+accuracy * whatever...;) or something else?
//I suppose that was my question to begin with.
//

EasyRaider
5th Mar 2002, 07:03 AM
In the Tracefire() you posted, TraceShot() is called at the second last line.

Keep in mind that it is vectors that are added here, not numbers. When two vectors are added, the x, y and z components are added separately.

Also, don't confuse the vectors X, Y, and Z in this code with the x, y and z components of a vector.

WheatPuppet
5th Mar 2002, 09:49 AM
Oh my god! How did I not notice that!
*whack* moron *whack*:stick:
I feel really dumb.
One more foolish question: when one vector is multiplied by a non-vector, each element of the vector is multiplied by that number, right?

Wormbo
5th Mar 2002, 10:10 AM
Just to make sure: :D
/ 2 \ /0.5\
X = | 3 | <-- these are vectors --> Y = |-1 |
\1.5/ \2.5/


multiplying a vector with float or int values:

/4\ <-- x-component
X * 2 = |6| <-- y-component of the vector
\3/ <-- z-component


adding two vectors:

/2.5\
X + Y = | 2 |
\ 4 /

WheatPuppet
5th Mar 2002, 08:00 PM
I think I might finally get this UnrealScript thing. Now I just gotta figure out what I want to do with this new skill...