void AimAtPlayer(UCanvas* Canvas, APawn* TargetPawn)
{
if (TargetPawn != NULL && mAPBPawn != NULL){
FName NameHeadBone = TargetPawn->Mesh->GetBoneName(6);
FVector VectorHead = TargetPawn->Mesh->GetBoneLocation(NameHeadBone,0);
FVector2D vHead = CalculateScreenCoordinate(pCanvas,TargetPawn->Mesh->GetBoneLocation(NameHeadBone,0));
pCanvas->Draw2DLine(pCanvas->ClipX/2,pCanvas->ClipY/2,vHead.X,vHead.Y,Red);
VectorHead = VectorHead -MyCameraLocation ;
AimAtRot = VectorHead****tation();
NormalizeRotation(AimAtRot);
FRotator* pAimAtRot = &AimAtRot;
if(GetAsyncKeyState(VK_RBUTTON))
{
mAPBPawn->SetCameraAimRotPawn(pAimAtRot);
}
}
}
float CurrentAngle = GetViewAngle( Target->Location, ViewLocation );
if ( CheckAngle( CurrentAngle, pPC->PlayerCamera->GetFOVAngle() ) )
{
if ( ( !TargetPawn
|| RadianToDegree(CurrentAngle) > BestAngle ) && APBPawn->PlayerCanSeeMe() )
{
BestAngle = RadianToDegree(CurrentAngle);
TargetPawn = Target;
}
}
