Code:
local Actor TraceHit, TraceHitLeft, TraceHitRight;
local vector HitLocation, HitNormal, HitLocationRight, HitNormalRight, HitLocationLeft, HitNormalLeft;
local vector Start, LeftStart, RightStart;
local vector End, LeftEnd, RightEnd;
local vector ViewRotToLoc;
local rotator ViewRotation;
local int TraceLength, TraceLengthLeft, TraceLengthRight;
ViewRotation = Pawn.GetViewRotation();
ViewRotToLoc = Vector(ViewRotation);
Start = Pawn.GetPawnViewLocation();
End = Pawn.GetPawnViewLocation() + (ViewRotToLoc * 2000);
LeftStart.Y = Start.Y + 160;
LeftEnd = LeftStart + (ViewRotToLoc * 2000);
RightStart.Y = Start.Y - 160;
RightEnd = RightStart + (ViewRotToLoc * 2000);
TraceHit = Trace(HitLocation, HitNormal, End, Start, true);
TraceHitLeft = Trace(HitLocationLeft, HitNormalLeft, LeftEnd, LeftStart, true);
TraceHitRight = Trace(HitLocationRight, HitNormalRight, RightEnd, RightStart, true);
if (TraceHitLeft != None)
{
TracelengthLeft = VSize(LeftStart - HitLocationLeft) - 500;
}
Else
{
TracelengthLeft = 2000;
}
if (TraceHitRight != None)
{
TracelengthRight = VSize(RightStart - HitLocationRight) - 500;
}
Else
{
TracelengthRight = 2000;
}
if (TraceHit != None)
{
Tracelength = VSize(Start - Hitlocation) - 500;
}
Else
{
Tracelength = 2000;
}
If (TraceLength == 2000 && TraceLengthLeft == 2000 && TraceLengthRight == 2000)
{
StrafeToLocation = End;
DrawDebugLine(End,Start,0,255,0,TRUE);
DrawDebugLine(LeftEnd,LeftStart,0,255,0,TRUE);
DrawDebugLine(RightEnd,RightStart,0,255,0,TRUE);
}
Else If (TraceLength <= TraceLengthLeft && TraceLength <= TraceLengthRight)
{
StrafeToLocation = Start + (ViewRotToLoc * TraceLength);
DrawDebugLine(End,Start,255,0,0,TRUE);
DrawDebugLine(LeftEnd,LeftStart,0,255,0,TRUE);
DrawDebugLine(RightEnd,RightStart,0,255,0,TRUE);
}
Else If (TraceLengthLeft <= TraceLengthRight)
{
StrafeToLocation = LeftStart + (ViewRotToLoc * TraceLengthLeft);
DrawDebugLine(End,Start,0,255,0,TRUE);
DrawDebugLine(LeftEnd,LeftStart,255,0,0,TRUE);
DrawDebugLine(RightEnd,RightStart,0,255,0,TRUE);
}
Else
{
StrafeToLocation = RightStart + (ViewRotToLoc * TraceLengthRight);
DrawDebugLine(End,Start,0,255,0,TRUE);
DrawDebugLine(LeftEnd,LeftStart,0,255,0,TRUE);
DrawDebugLine(RightEnd,RightStart,255,0,0,TRUE);
}
}
There's a lot more to it, but this is the parts relevant to the issue.
Bookmarks