not sure if this helps, but I have an item in my game that when used, you possess the pawn you hit with the weapon. here is the Code for the traceswing function:
Code:
function TraceSwing()
{
local UTPawn V, Best, tempHolder;
local vector ViewDir, PawnLoc2D, VLoc2D, ReachVector;
local float NewDot, BestDot;
local Actor HitActor;
local Vector HitLoc, HitNorm, SwordTip, SwordHilt, Momentum;
local int DamageAmount;
tempHolder = UTPawn(OwnerPawn);
// Pick best nearby vehicle
PawnLoc2D = OwnerPawn.Location;
PawnLoc2D.Z = 0;
ViewDir = vector(OwnerPawn.Rotation);
ReachVector=ViewDir;
ReachVector.X=ReachVector.X+100;
//`Log("================CHECK RADIUS:" $Pawn.VehicleCheckRadius);
ForEach OwnerPawn.OverlappingActors(class'UTPawn', V, 100,,true)
{
// Prefer pawns that Pawn is facing
VLoc2D = V.Location;
Vloc2D.Z = 0;
NewDot = Normal(VLoc2D-PawnLoc2D) Dot ViewDir;
//`Log("================FOUND:" $V.Name);
if ( NewDot>0.8)
{
// check that pawn is visible
if ( FastTrace(V.Location,OwnerPawn.Location) )
{
//Best = V;
BestDot = NewDot;
if(V != None && V.Controller != None)
{
//Pawn(V).Controller.Unpossess();
//Pawn(V).SetOwner(V);
OwnerPawn.Controller.Possess(V,false);
}
}
}
}
Bookmarks