本文整理汇总了C++中ACharacter::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ ACharacter::GetName方法的具体用法?C++ ACharacter::GetName怎么用?C++ ACharacter::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACharacter
的用法示例。
在下文中一共展示了ACharacter::GetName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SearchForTarget
void ABaseController::SearchForTarget()
{
if (GetPawn() == NULL || StopSearching)
{
return;
}
bool canSeePlayer = false;
FHitResult hit(ForceInit);
FCollisionQueryParams traceParams = FCollisionQueryParams(FName(TEXT("RV_Trace")), true, Self);
traceParams.bTraceComplex = true;
traceParams.bTraceAsyncScene = true;
FVector EnemyLocation = Self->GetActorLocation();
for (FConstPawnIterator i = World->GetPawnIterator(); i; ++i)
{
ACharacter* poesibleTarget = Cast<ACharacter>(*i);
if (poesibleTarget != Cast<ACharacter>(Self) && poesibleTarget != NULL)
{
FVector possibleTargetLocation = poesibleTarget->GetActorLocation();
bool bHit = World->LineTraceSingleByChannel(hit, Self->EyeLocation, possibleTargetLocation, ECC_Visibility, traceParams);
bool bPersistent = true;
float LifeTime = 5.f;
// @fixme, draw line with thickneES = 2.f?
if (bHit && hit.bBlockingHit)
{
// Red up to the blocking hit, green thereafter
//DrawDebugLine(World, Self->EyeLocation, hit.ImpactPoint, FColor::Red, bPersistent, LifeTime);
//DrawDebugLine(World, hit.ImpactPoint, possibleTargetLocation, FColor::Green, bPersistent, LifeTime);
//DrawDebugPoint(World, hit.ImpactPoint, 16.f, FColor::Red, bPersistent, LifeTime);
}
else
{
// no hit means all red
//DrawDebugLine(World, Self->EyeLocation, possibleTargetLocation, FLinearColor::Red, bPersistent, LifeTime);
}
if (hit.GetActor() && hit.GetActor()->GetName() == poesibleTarget->GetName() && hit.bBlockingHit)
{
if (Self->EState != EnemyState::ES_Searching)
TargetsLastKnownPosition = hit.GetActor()->GetActorLocation();
BBComp->SetValue<UBlackboardKeyType_Vector>(TargetsLastKnownPositionID, TargetsLastKnownPosition);
float distanceFromPoESibleTarget = FVector::Dist(EnemyLocation, possibleTargetLocation);
if (distanceFromPoESibleTarget <= Self->SightRange && distanceFromPoESibleTarget > Self->AttackRange && Self->AttackCompleted)
{
SetTarget(poesibleTarget, distanceFromPoESibleTarget);
ResetFocusActor();
SetState(EnemyState::ES_Chasing, "Chasing");
BBComp->SetValue<UBlackboardKeyType_Bool>(MovedToLastKnownPositionID, false);
}
else if (distanceFromPoESibleTarget <= Self->AttackRange && Self->AttackCompleted)
{
Self->AttackStarted = true;
Self->AttackCompleted = false;
SetTarget(poesibleTarget, distanceFromPoESibleTarget);
SetFocusActor(Cast<AActor>(Target));
AttackLocation = poesibleTarget->GetActorLocation();
SetState(EnemyState::ES_Attacking, "Attacking");
BBComp->SetValue<UBlackboardKeyType_Bool>(MovedToLastKnownPositionID, false);
}
else if (Self->AttackCompleted)
{
ResetFocusActor();
SetState(EnemyState::ES_Searching, "Searching");
SearchForTargetAtLastKnownPosition();
}
}
else if (hit.GetActor() && hit.GetActor()->GetName() != poesibleTarget->GetName() && hit.bBlockingHit)
{
if (Self->EState != EnemyState::ES_Searching)
SearchForTargetAtLastKnownPosition();
Self->AttackStarted = false;
Self->AttackCompleted = true;
ResetFocusActor();
SetState(EnemyState::ES_Searching, "Searching");
}
}
}
}