本文整理汇总了C++中APawn::GetController方法的典型用法代码示例。如果您正苦于以下问题:C++ APawn::GetController方法的具体用法?C++ APawn::GetController怎么用?C++ APawn::GetController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类APawn
的用法示例。
在下文中一共展示了APawn::GetController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CollectNearbyAgents
void UNavLinkCustomComponent::CollectNearbyAgents(TArray<UPathFollowingComponent*>& NotifyList)
{
AActor* MyOwner = GetOwner();
if (BroadcastRadius < KINDA_SMALL_NUMBER || MyOwner == NULL)
{
return;
}
static FName SmartLinkBroadcastTrace(TEXT("SmartLinkBroadcastTrace"));
FCollisionQueryParams Params(SmartLinkBroadcastTrace, false, MyOwner);
TArray<FOverlapResult> OverlapsL, OverlapsR;
const FVector LocationL = GetStartPoint();
const FVector LocationR = GetEndPoint();
const float LinkDistSq = (LocationL - LocationR).SizeSquared();
const float DistThresholdSq = FMath::Square(BroadcastRadius * 0.25f);
if (LinkDistSq > DistThresholdSq)
{
GetWorld()->OverlapMultiByChannel(OverlapsL, LocationL, FQuat::Identity, BroadcastChannel, FCollisionShape::MakeSphere(BroadcastRadius), Params);
GetWorld()->OverlapMultiByChannel(OverlapsR, LocationR, FQuat::Identity, BroadcastChannel, FCollisionShape::MakeSphere(BroadcastRadius), Params);
}
else
{
const FVector MidPoint = (LocationL + LocationR) * 0.5f;
GetWorld()->OverlapMultiByChannel(OverlapsL, MidPoint, FQuat::Identity, BroadcastChannel, FCollisionShape::MakeSphere(BroadcastRadius), Params);
}
TArray<APawn*> PawnList;
for (int32 i = 0; i < OverlapsL.Num(); i++)
{
APawn* MovingPawn = Cast<APawn>(OverlapsL[i].GetActor());
if (MovingPawn && MovingPawn->GetController())
{
PawnList.Add(MovingPawn);
}
}
for (int32 i = 0; i < OverlapsR.Num(); i++)
{
APawn* MovingPawn = Cast<APawn>(OverlapsR[i].GetActor());
if (MovingPawn && MovingPawn->GetController())
{
PawnList.AddUnique(MovingPawn);
}
}
for (int32 i = 0; i < PawnList.Num(); i++)
{
UPathFollowingComponent* NavComp = PawnList[i]->GetController()->FindComponentByClass<UPathFollowingComponent>();
if (NavComp)// && NavComp->WantsSmartLinkUpdates())
{
NotifyList.Add(NavComp);
}
}
}
示例2: Spawn
//----------------------------------------------------------------------//
// FAITestSpawnInfo
//----------------------------------------------------------------------//
bool FAITestSpawnInfo::Spawn(AFunctionalAITest* AITest) const
{
check(AITest);
bool bSuccessfullySpawned = false;
APawn* SpawnedPawn = UAIBlueprintHelperLibrary::SpawnAIFromClass(AITest->GetWorld(), PawnClass, BehaviorTree
, SpawnLocation->GetActorLocation()
, SpawnLocation->GetActorRotation()
, /*bNoCollisionFail=*/true);
if (SpawnedPawn == NULL)
{
FString FailureMessage = FString::Printf(TEXT("Failed to spawn \'%s\' pawn (\'%s\' set) ")
, *GetNameSafe(PawnClass)
, *SpawnSetName.ToString());
UE_LOG(LogFunctionalTest, Warning, TEXT("%s"), *FailureMessage);
}
else if (SpawnedPawn->GetController() == NULL)
{
FString FailureMessage = FString::Printf(TEXT("Spawned Pawn %s (\'%s\' set) has no controller ")
, *GetNameSafe(SpawnedPawn)
, *SpawnSetName.ToString());
UE_LOG(LogFunctionalTest, Warning, TEXT("%s"), *FailureMessage);
}
else
{
AITest->AddSpawnedPawn(*SpawnedPawn);
bSuccessfullySpawned = true;
}
return bSuccessfullySpawned;
}
示例3: GetBlackboard
UBlackboardComponent* UKismetAIHelperLibrary::GetBlackboard(AActor* Target)
{
UBlackboardComponent* BlackboardComp = NULL;
APawn* TargetPawn = Cast<APawn>(Target);
if (TargetPawn && TargetPawn->GetController())
{
BlackboardComp = TargetPawn->GetController()->FindComponentByClass<UBlackboardComponent>();
}
if (BlackboardComp == NULL && Target)
{
BlackboardComp = Target->FindComponentByClass<UBlackboardComponent>();
}
return BlackboardComp;
}
示例4: PerformAction
bool UPawnActionsComponent::PerformAction(APawn& Pawn, UPawnAction& Action, TEnumAsByte<EAIRequestPriority::Type> Priority)
{
bool bSuccess = false;
ensure(Priority < EAIRequestPriority::MAX);
if (Pawn.GetController())
{
UPawnActionsComponent* ActionComp = Pawn.GetController()->FindComponentByClass<UPawnActionsComponent>();
if (ActionComp)
{
ActionComp->PushAction(Action, Priority);
bSuccess = true;
}
}
return bSuccess;
}
示例5: GetAIController
AAIController* UAIBlueprintHelperLibrary::GetAIController(AActor* ControlledActor)
{
APawn* AsPawn = Cast<APawn>(ControlledActor);
if (AsPawn != nullptr)
{
return Cast<AAIController>(AsPawn->GetController());
}
return Cast<AAIController>(ControlledActor);
}
示例6: FindInstanceInActor
UBehaviorTreeComponent* FBehaviorTreeDebugger::FindInstanceInActor(AActor* TestActor)
{
UBehaviorTreeComponent* FoundInstance = NULL;
if (TestActor)
{
APawn* TestPawn = Cast<APawn>(TestActor);
if (TestPawn && TestPawn->GetController())
{
FoundInstance = TestPawn->GetController()->FindComponentByClass<UBehaviorTreeComponent>();
}
if (FoundInstance == NULL)
{
FoundInstance = TestActor->FindComponentByClass<UBehaviorTreeComponent>();
}
}
return FoundInstance;
}
示例7: ResumePathFollowing
void ANavLinkProxy::ResumePathFollowing(AActor* Agent)
{
if (Agent)
{
UPathFollowingComponent* PathComp = Agent->FindComponentByClass<UPathFollowingComponent>();
if (PathComp == NULL)
{
APawn* PawnOwner = Cast<APawn>(Agent);
if (PawnOwner && PawnOwner->GetController())
{
PathComp = PawnOwner->GetController()->FindComponentByClass<UPathFollowingComponent>();
}
}
if (PathComp)
{
PathComp->FinishUsingCustomLink(SmartLinkComp);
}
}
}
示例8: GetBlackboard
UBlackboardComponent* UAIBlueprintHelperLibrary::GetBlackboard(AActor* Target)
{
UBlackboardComponent* BlackboardComp = nullptr;
if (Target != nullptr)
{
APawn* TargetPawn = Cast<APawn>(Target);
if (TargetPawn && TargetPawn->GetController())
{
BlackboardComp = TargetPawn->GetController()->FindComponentByClass<UBlackboardComponent>();
}
if (BlackboardComp == nullptr)
{
BlackboardComp = Target->FindComponentByClass<UBlackboardComponent>();
}
}
return BlackboardComp;
}
示例9: TickPathNavigation
void UBTTask_FlyTo::TickPathNavigation(UBehaviorTreeComponent& OwnerComp, FBT_FlyToTarget* MyMemory, float DeltaSeconds)
{
const auto& queryResults = MyMemory->QueryResults;
APawn* pawn = OwnerComp.GetAIOwner()->GetPawn();
if (DebugParams.bVisualizePawnAsVoxels)
NavigationManager->Debug_DrawVoxelCollisionProfile(Cast<UPrimitiveComponent>(pawn->GetRootComponent()));
FVector flightDirection = queryResults.PathSolutionOptimized[MyMemory->solutionTraversalIndex] - pawn->GetActorLocation();
//auto navigator = Cast<IDonNavigator>(pawn);
// Add movement input:
if (MyMemory->bIsANavigator)
{
// Customized movement handling for advanced users:
IDonNavigator::Execute_AddMovementInputCustom(pawn, flightDirection, 1.f);
}
else
{
// Default movement (handled by Pawn or Character class)
pawn->AddMovementInput(flightDirection, 1.f);
}
FVector test = FVector(10,10,100);
//test.
// Reached next segment:
if (flightDirection.Size() <= MinimumProximityRequired)
{
// Goal reached?
if (MyMemory->solutionTraversalIndex == queryResults.PathSolutionOptimized.Num() - 1)
{
UBlackboardComponent* blackboard = pawn->GetController()->FindComponentByClass<UBlackboardComponent>();
blackboard->SetValueAsBool(FlightResultKey.SelectedKeyName, true);
blackboard->SetValueAsBool(KeyToFlipFlopWhenTaskExits.SelectedKeyName, !blackboard->GetValueAsBool(KeyToFlipFlopWhenTaskExits.SelectedKeyName));
// Unregister all dynamic collision listeners. We've completed our task and are no longer interested in listening to these:
NavigationManager->StopListeningToDynamicCollisionsForPath(MyMemory->DynamicCollisionListener, queryResults);
FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded);
return;
}
else
{
MyMemory->solutionTraversalIndex++;
}
}
}
示例10: GetAIControllerForActor
AAIController* UAITask::GetAIControllerForActor(AActor* Actor)
{
AAIController* Result = Cast<AAIController>(Actor);
if (Result == nullptr)
{
APawn* AsPawn = Cast<APawn>(Actor);
if (AsPawn != nullptr)
{
Result = Cast<AAIController>(AsPawn->GetController());
}
}
return Result;
}
示例11: SetCameraRotation
FExecStatus FCameraCommandHandler::SetCameraRotation(const TArray<FString>& Args)
{
if (Args.Num() == 4) // ID, Pitch, Roll, Yaw
{
int32 CameraId = FCString::Atoi(*Args[0]); // TODO: Add support for multiple cameras
float Pitch = FCString::Atof(*Args[1]), Yaw = FCString::Atof(*Args[2]), Roll = FCString::Atof(*Args[3]);
FRotator Rotator = FRotator(Pitch, Yaw, Roll);
APawn* Pawn = FUE4CVServer::Get().GetPawn();
AController* Controller = Pawn->GetController();
Controller->ClientSetRotation(Rotator); // Teleport action
// SetActorRotation(Rotator); // This is not working
return FExecStatus::OK();
}
return FExecStatus::InvalidArgument;
}
示例12: PyErr_Format
PyObject *py_ue_pawn_get_controller(ue_PyUObject * self, PyObject * args) {
ue_py_check(self);
if (!self->ue_object->IsA<APawn>()) {
return PyErr_Format(PyExc_Exception, "uobject is not an APawn");
}
APawn *pawn = (APawn *)self->ue_object;
ue_PyUObject *ret = ue_get_python_wrapper(pawn->GetController());
if (!ret)
return PyErr_Format(PyExc_Exception, "uobject is in invalid state");
Py_INCREF(ret);
return (PyObject *)ret;
}
示例13: CollectDataToReplicate
void UPerceptionGameplayDebuggerObject::CollectDataToReplicate(APlayerController* MyPC, AActor *SelectedActor)
{
Super::CollectDataToReplicate(MyPC, SelectedActor);
#if ENABLED_GAMEPLAY_DEBUGGER
if (GetWorld()->TimeSeconds - LastDataCaptureTime < 2)
{
return;
}
APawn* MyPawn = Cast<APawn>(SelectedActor);
if (MyPawn)
{
AAIController* BTAI = Cast<AAIController>(MyPawn->GetController());
if (BTAI)
{
UAIPerceptionComponent* PerceptionComponent = BTAI->GetAIPerceptionComponent();
if (PerceptionComponent == nullptr)
{
PerceptionComponent = MyPawn->FindComponentByClass<UAIPerceptionComponent>();
}
if (PerceptionComponent)
{
TArray<FString> PerceptionTexts;
GenericShapeElements.Reset();
PerceptionComponent->GrabGameplayDebuggerData(PerceptionTexts, GenericShapeElements);
DistanceFromPlayer = DistanceFromSensor = -1;
if (MyPC && MyPC->GetPawn())
{
DistanceFromPlayer = (MyPawn->GetActorLocation() - MyPC->GetPawn()->GetActorLocation()).Size();
DistanceFromSensor = SensingComponentLocation != FVector::ZeroVector ? (SensingComponentLocation - MyPC->GetPawn()->GetActorLocation()).Size() : -1;
}
}
UAIPerceptionSystem* PerceptionSys = UAIPerceptionSystem::GetCurrent(MyPawn->GetWorld());
if (PerceptionSys)
{
PerceptionLegend = PerceptionSys->GetPerceptionDebugLegend();
}
}
}
#endif
}
示例14: PlotHitLine
AActor* UWeaponComponent::PlotHitLine(float LineLength, AController* Instigator, TSubclassOf<UDamageType> DamageType, UGameplaySystemComponent* GameplaySystem)
{
if (this->GetOwner() == nullptr)
return nullptr;
AController* OwnerAsController = dynamic_cast<AController*>(this->GetOwner());
if (OwnerAsController == nullptr)
return nullptr;
if (OwnerAsController->GetPawn() == nullptr)
return nullptr;
FVector TraceStart = OwnerAsController->GetPawn()->GetActorLocation();
FVector TraceEnd = OwnerAsController->GetPawn()->GetActorLocation();
{
FRotator Rotation = OwnerAsController->GetControlRotation();
TraceEnd += Rotation.RotateVector(FVector(LineLength, 0, 0));
}
// Setup the trace query
FCollisionQueryParams TraceParams = FCollisionQueryParams();
TraceParams.AddIgnoredActor(OwnerAsController->GetPawn());
TraceParams.bTraceAsyncScene = true;
FCollisionResponseParams CollisionParams = FCollisionResponseParams();
FHitResult HitResult;
if (this->GetWorld()->LineTraceSingleByChannel(HitResult, TraceStart, TraceEnd, ECC_GameTraceChannel1, TraceParams, CollisionParams))
{
if (GameplaySystem == nullptr)
return nullptr;
APawn* TargetAsPawn = dynamic_cast<APawn*>(HitResult.Actor.Get());
if (TargetAsPawn)
{
TargetAsPawn->GetController()->TakeDamage(GameplaySystem->GetInfightAttackPoints(), FDamageEvent(DamageType), Instigator, Instigator->GetPawn());
}
return HitResult.GetActor();
}
else
{
return nullptr;
}
}
示例15: PyErr_Format
PyObject *py_ue_simple_move_to_location(ue_PyUObject *self, PyObject * args) {
ue_py_check(self);
FVector vec;
if (!py_ue_vector_arg(args, vec))
return NULL;
UWorld *world = ue_get_uworld(self);
if (!world)
return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");
APawn *pawn = nullptr;
if (self->ue_object->IsA<APawn>()) {
pawn = (APawn *)self->ue_object;
}
else if (self->ue_object->IsA<UActorComponent>()) {
UActorComponent *component = (UActorComponent *)self->ue_object;
AActor *actor = component->GetOwner();
if (actor) {
if (actor->IsA<APawn>()) {
pawn = (APawn *)actor;
}
}
}
if (!pawn)
return PyErr_Format(PyExc_Exception, "uobject is not a pawn");
AController *controller = pawn->GetController();
if (!controller)
return PyErr_Format(PyExc_Exception, "Pawn has no controller");
world->GetNavigationSystem()->SimpleMoveToLocation(controller, vec);
Py_INCREF(Py_None);
return Py_None;
}