Can anybody please explain trace() to me?

  • 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.

RestInPieces

New Member
Sep 20, 2001
65
0
0
www.Creep-World.net
Hi guys, i wanted to make a trace and didnt quite understand the trace (), can somebody explain the Vars and what they are good for to me? Especially HitNormal i don't understand, and where do i put the direction i want the trace to go? And if i dont pass a StartLoc, will this loc be the classowner's location? Please help me, thx, RiP.
 

Shiit

Shiit
Dec 19, 2000
168
0
0
native(277) final function Actor Trace
(
out vector HitLocation,
out vector HitNormal,
vector TraceEnd,
optional vector TraceStart,
optional bool bTraceActors,
optional vector Extent
);

Hitlocation is the place of the first collision with either world geometry or an actor. If nothing was hit, it'll probably be the same as TraceEnd. (or not) Remember that "out" means that this variable not only goes IN, but comes out too (in this case, it only comes out, so you use an empty var for this, and that var will contain the hitlocation after Trace is done.)
HitNormal is a vector that'll contain the normal (the line that's 90 degrees on a surface) of the surface that the Trace line crosses first.
TraceEnd is the end of the Trace line. If something was hit, it'll never reach this point. For weapons, make this quite far away. Note that this is also where you specify the direction of the Trace. If you want to do the trace in direction X, this'll have to be "Location+vector(X)*1000" (supposed that the trace starts at "Location")
Since TraceStart is optional, I suppose it'll use the location of the actor Trace was called from. Just remember that the location of weapons is never used, so when you use it in a weapon you WILL have to specify this variable.

I don't know what the last vars mean, sorry.
 

RestInPieces

New Member
Sep 20, 2001
65
0
0
www.Creep-World.net
you said "the line that's 90 degrees on a surface".
What do you mean by that? the Angle beween the line and the surface is 90 degrees? like that:

|----------------------------- <- Normal
^
Surface

thx, RiP
 

Papapishu

我是康
Jun 18, 2001
2,043
0
0
43
void
www.vovoid.com
Yeah, the HitLocation is quite usefull, yes?
Since it tells you where you have hit...
And the Traceend is good too, say if you wanna do a gun that has only a certain range, like the impacthammer...
Imagine if thatone had an infinite range... :)

Tracestart can be useful if you want the trace to start from somewhere else...
Like say your pawn has a weapon that's far away (not in the middle of the body) like on the head or feet.
Say a helmet with a laser-cannon or that he can kick someone, then you can use it to simulate a hit that comes from another angle...
The bTraceactors is a bool, so i guess that if you set it to true, it will skip any actor it comes across...

I'm not sure what extent means either...