Still not clear about traces

  • 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.
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.
 
Here we go! Explain this.

Code:
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

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Code:
	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;"
 
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

Crazy coder
Sep 21, 2001
74
0
0
43
Norway
X, Y and Z are set in GetAxes().

And in case you have missed it, the actual tracing is done in Pawn.TraceShot().
 
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:
Code:
//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

Crazy coder
Sep 21, 2001
74
0
0
43
Norway
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.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Just to make sure: :D
Code:
    / 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 /