Hi,
I have created the simple first person shooting game with unreal scripts. It's working quite good although it has several drawbacks.
One limitation I have noticed is that selection functionality of friendly soldiers (NPC). I use trace(); for the pawn selection as bellow.
But I have to make several attempts to select as it is always not guarantee to hit on the pawn's collision box as expected. (especially while I am walking)PHP Code:function RayCast()
{
local vector loc, norm, end;
local TraceHitInfo hitInfo;
local Actor traceHit;
Local VHUserPawn TempVH, User;
foreach DynamicActors(class'VHUserPawn',TempVH)
{
if(TempVH.IsA('VHUserPawn'))
{
User = TempVH;
break;
}
}
end = User.Location + normal(vector(User.Rotation))*32768; // trace to "infinity"
traceHit = trace(loc, norm, end, Location, true,, hitInfo);
...
...
}
So I think to find out the closest pawn (NPC) to the ray. I have stated what I have in mind as bellow.
In this case pawn A should be selected. I need to know how to do it from unreal scripts. It will be much helpful your comments...
Thankx



Reply With Quote




Bookmarks