这篇教程C++ APawn类代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中APawn类的典型用法代码示例。如果您正苦于以下问题:C++ APawn类的具体用法?C++ APawn怎么用?C++ APawn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。 在下文中一共展示了APawn类的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: FNamevoid ADuckTower::Shoot(float distance){ /* const FName filename = FName(TEXT("Blueprint'/Game/Blueprints/PickUp.PickUp'")); FVector loc = GetAttachParentActor()->GetActorLocation(); FRotator rot = GetAttachParentActor()->GetActorRotation(); SpawnBP(GetWorld(), (UClass*)LoadObjFromPath<UBlueprint>(&filename), loc, rot); */ APawn *player = UGameplayStatics::GetPlayerController(GetWorld(), 1)->GetControlledPawn(); int randomValue = distance / 10000; FVector vec = player->GetActorLocation() + FVector(FMath::RandRange(-randomValue, randomValue), FMath::RandRange(-randomValue, randomValue), 0.0f); //+ player->GetRootPrimitiveComponent()->GetPhysicsLinearVelocity() *DeltaSeconds * 10; FVector vec2 = GetActorLocation(); FVector Direction = vec - vec2; FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator(); FRotator test2 = FRotator(1.0f, 0.0f, 0.0f); FRotator finalrot = FRotator(test.Quaternion() * test2.Quaternion()); FVector forward = GetActorForwardVector(); finalrot.Roll = -finalrot.Roll; finalrot.Yaw = -finalrot.Yaw; finalrot.Pitch = -finalrot.Pitch; FVector loc = GetActorLocation() + forward * 500.0f; FRotator rot = GetActorRotation(); AActor* actor = GetWorld()->SpawnActor<AActor>(BulletBlueprint, loc, GetActorRotation()); actor->SetActorScale3D(FVector(3.0f, 3.0f, 3.0f)); //actor->GetRootPrimitiveComponent()->AddImpulse(actor->GetActorForwardVector()* 5000.0f); //actor->GetRootPrimitiveComponent()->SetPhysicsLinearVelocity(actor->GetActorForwardVector()*10000.0f); //* (distance/10000 * 1.0f));}
开发者ID:SlooBo,项目名称:RalliaPerkele,代码行数:30,
示例2: GetPawn/** Function called to search for an enemy - parameter void: - returns: void */void AEnemyController::SearchForEnemy(){ APawn* MyEnemy = GetPawn(); if (MyEnemy == NULL) return; const FVector MyLoc = MyEnemy->GetActorLocation(); float BestDistSq = MAX_FLT; ATankCharacter* BestPawn = NULL; for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; It++) { ATankCharacter* TestPawn = Cast<ATankCharacter>(*It); if (TestPawn) { const float DistSq = FVector::Dist(TestPawn->GetActorLocation(), MyLoc); bool canSee = LineOfSightTo(TestPawn); //choose the closest option to the AI that can be seen if (DistSq < BestDistSq && canSee) { BestDistSq = DistSq; BestPawn = TestPawn; } } } if (BestPawn) { GEngine->AddOnScreenDebugMessage(0, 1.0f, FColor::Green, BestPawn->GetName()); SetEnemy(BestPawn); }}
开发者ID:burnsm,项目名称:Tanks,代码行数:40,
示例3: GetPawnvoid AFournoidAIController::FindClosestEnemy(){ APawn* MyBot = GetPawn(); if (MyBot == NULL) { return; } const FVector MyLoc = MyBot->GetActorLocation(); float BestDistSq = MAX_FLT; AFournoidCharacter* BestPawn = NULL; for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; ++It) { AFournoidCharacter* TestPawn = Cast<AFournoidCharacter>(*It); if (TestPawn && TestPawn->IsAlive() && TestPawn->GetController()->IsA(APlayerController::StaticClass())) { const float DistSq = (TestPawn->GetActorLocation() - MyLoc).SizeSquared(); if (DistSq < BestDistSq && sqrt(DistSq) < 2500.f ) { BestDistSq = DistSq; BestPawn = TestPawn; } } } if (BestPawn) { SetEnemy(BestPawn); }else { SetEnemy(NULL); }}
开发者ID:Roger7410,项目名称:Fournoid,代码行数:32,
示例4: DebugNextPawnvoid AGameplayDebuggingReplicator::DebugNextPawn(UClass* CompareClass, APawn* CurrentPawn){#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) APawn* LastSeen = nullptr; APawn* FirstSeen = nullptr; // Search through the list looking for the next one of this type for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; It++) { APawn* IterPawn = *It; if (IterPawn->IsA(CompareClass)) { if (LastSeen == CurrentPawn) { ServerSetActorToDebug(IterPawn); return; } LastSeen = IterPawn; if (FirstSeen == nullptr) { FirstSeen = IterPawn; } } } // See if we need to wrap around the list if (FirstSeen != nullptr) { ServerSetActorToDebug(FirstSeen); }#endif}
开发者ID:PopCap,项目名称:GameIdea,代码行数:30,
示例5: GetAttachParentActorvoid ADuckTower::Tick(float DeltaSeconds){ Super::Tick(DeltaSeconds); /* AActor *actor = GetAttachParentActor(); FVector actor2 = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorLocation(); FRotator newRotation = FRotationMatrix::MakeFromX(actor2 - actor->GetActorLocation()).Rotator(); GetAttachParentActor()->SetActorRotation(newRotation); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, actor->GetName()); *//* FVector actor2 = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorLocation(); FVector actor = GetAttachParentActor()->GetActorLocation(); FVector Direction = actor - actor2; FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator(); GetAttachParentActor()->SetActorRotation(test); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, actor2.ToString()); */ //GetAttachParentActor()->SetActorLocation(FVector(0.0f, 0.0f, (float)testNumber)); //testNumber += 1.f; APawn *player = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn(); FVector actor2 = player->GetActorLocation(); //+ player->GetRootPrimitiveComponent()->GetPhysicsLinearVelocity() *DeltaSeconds * 10; FVector actor = GetActorLocation(); FVector Direction = actor - actor2; FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator(); FRotator test2 = FRotator(1.0f, 0.0f, 0.0f); FRotator finalrot = FRotator(test.Quaternion() * test2.Quaternion()); FVector vec2 = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorLocation(); FVector vec = GetActorLocation(); float distance = FVector::Dist(actor, actor2); //finalrot.Pitch -= 10 - distance / 10000 * 10; //SetActorRotation(finalrot); TArray<UStaticMeshComponent*> comps; GetComponents(comps); /* for (auto StaticMeshComponent : comps) { StaticMeshComponent->SetVisibility(true); StaticMeshComponent->SetWorldRotation(finalrot); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, StaticMeshComponent->GetComponentRotation().ToString()); }*/ if (UGameplayStatics::GetPlayerController(GetWorld(), 0)->WasInputKeyJustPressed(EKeys::I)) { } if (shootTimer <= 0.f) { Shoot(distance); shootTimer = 2.f; } else shootTimer -= DeltaSeconds; //GetAttachParentActor()->GetRootPrimitiveComponent()->AddImpulse(UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorForwardVector()); //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(testNumber)); //GetAttachParentActor()->SetActorRotation()}
开发者ID:SlooBo,项目名称:RalliaPerkele,代码行数:60,
示例6: GetActorRotationFExecStatus FCameraCommandHandler::GetActorRotation(const TArray<FString>& Args){ APawn* Pawn = FUE4CVServer::Get().GetPawn(); FRotator CameraRotation = Pawn->GetControlRotation(); FString Message = FString::Printf(TEXT("%.3f %.3f %.3f"), CameraRotation.Pitch, CameraRotation.Yaw, CameraRotation.Roll); return FExecStatus::OK(Message);}
开发者ID:Batname,项目名称:unrealcv,代码行数:7,
示例7: GetActorLocationFExecStatus FCameraCommandHandler::GetActorLocation(const TArray<FString>& Args){ APawn* Pawn = FUE4CVServer::Get().GetPawn(); FVector CameraLocation = Pawn->GetActorLocation(); FString Message = FString::Printf(TEXT("%.3f %.3f %.3f"), CameraLocation.X, CameraLocation.Y, CameraLocation.Z); return FExecStatus::OK(Message);}
开发者ID:Batname,项目名称:unrealcv,代码行数:7,
示例8: SpawnAIFromClassAPawn* UAIBlueprintHelperLibrary::SpawnAIFromClass(UObject* WorldContextObject, TSubclassOf<APawn> PawnClass, UBehaviorTree* BehaviorTree, FVector Location, FRotator Rotation, bool bNoCollisionFail){ APawn* NewPawn = NULL; UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject); if (World && *PawnClass) { FActorSpawnParameters ActorSpawnParams; ActorSpawnParams.bNoCollisionFail = bNoCollisionFail; NewPawn = World->SpawnActor<APawn>(*PawnClass, Location, Rotation, ActorSpawnParams); if (NewPawn != NULL) { if (NewPawn->Controller == NULL) { // NOTE: SpawnDefaultController ALSO calls Possess() to possess the pawn (if a controller is successfully spawned). NewPawn->SpawnDefaultController(); } if (BehaviorTree != NULL) { AAIController* AIController = Cast<AAIController>(NewPawn->Controller); if (AIController != NULL) { AIController->RunBehaviorTree(BehaviorTree); } } } } return NewPawn;}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:32,
示例9: GetCameraRotationFExecStatus FCameraCommandHandler::GetCameraRotation(const TArray<FString>& Args){ if (Args.Num() == 1) { bool bIsMatinee = false; FRotator CameraRotation; ACineCameraActor* CineCameraActor = nullptr; for (AActor* Actor : this->GetWorld()->GetCurrentLevel()->Actors) { // if (Actor && Actor->IsA(AMatineeActor::StaticClass())) // AMatineeActor is deprecated if (Actor && Actor->IsA(ACineCameraActor::StaticClass())) { bIsMatinee = true; CameraRotation = Actor->GetActorRotation(); break; } } if (!bIsMatinee) { int32 CameraId = FCString::Atoi(*Args[0]); // TODO: Add support for multiple cameras APawn* Pawn = FUE4CVServer::Get().GetPawn(); CameraRotation = Pawn->GetControlRotation(); } FString Message = FString::Printf(TEXT("%.3f %.3f %.3f"), CameraRotation.Pitch, CameraRotation.Yaw, CameraRotation.Roll); return FExecStatus::OK(Message); } return FExecStatus::Error("Number of arguments incorrect");}
开发者ID:Batname,项目名称:unrealcv,代码行数:32,
示例10: check//----------------------------------------------------------------------//// 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;}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:38,
示例11: UE_LOGvoid AVehicleSpawnerBase::SpawnVehicleAttempt(){ if(Vehicles.Num()>=NumberOfVehicles) { UE_LOG(LogCarla, Log, TEXT("All vehicles spawned correctly")); return; } APlayerStart* spawnpoint = GetRandomSpawnPoint(); APawn* playerpawn = UGameplayStatics::GetPlayerPawn(GetWorld(),0); const float DistanceToPlayer = playerpawn&&spawnpoint? FVector::Distance(playerpawn->GetActorLocation(),spawnpoint->GetActorLocation()):0.0f; float NextTime = TimeBetweenSpawnAttemptsAfterBegin; if(DistanceToPlayer>DistanceToPlayerBetweenSpawnAttemptsAfterBegin) { if(SpawnVehicleAtSpawnPoint(*spawnpoint)!=nullptr) { UE_LOG(LogCarla, Log, TEXT("Vehicle %d/%d late spawned"), Vehicles.Num(), NumberOfVehicles); } } else { NextTime /= 2.0f; } if(Vehicles.Num()<NumberOfVehicles) { auto &timemanager = GetWorld()->GetTimerManager(); if(AttemptTimerHandle.IsValid()) timemanager.ClearTimer(AttemptTimerHandle); timemanager.SetTimer(AttemptTimerHandle,this, &AVehicleSpawnerBase::SpawnVehicleAttempt,NextTime,false,-1); } else { UE_LOG(LogCarla, Log, TEXT("All vehicles spawned correctly")); }}
开发者ID:cyy1991,项目名称:carla,代码行数:34,
示例12: DrawOverHeadInformationvoid AGameplayDebuggingHUDComponent::DrawOverHeadInformation(APlayerController* PC, class UGameplayDebuggingComponent *DebugComponent){#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) APawn* MyPawn = Cast<APawn>(DebugComponent->GetSelectedActor()); const FVector Loc3d = MyPawn ? MyPawn->GetActorLocation() + FVector(0.f, 0.f, MyPawn->GetSimpleCollisionHalfHeight()) : FVector::ZeroVector; if (OverHeadContext.Canvas->SceneView == NULL || OverHeadContext.Canvas->SceneView->ViewFrustum.IntersectBox(Loc3d, FVector::ZeroVector) == false) { return; } const FVector ScreenLoc = OverHeadContext.Canvas->Project(Loc3d); static const FVector2D FontScale(1.f, 1.f); UFont* Font = GEngine->GetSmallFont(); float TextXL = 0.f; float YL = 0.f; FString ObjectName = FString::Printf( TEXT("{yellow}%s {white}(%s)"), *DebugComponent->ControllerName, *DebugComponent->PawnName); CalulateStringSize(OverHeadContext, OverHeadContext.Font, ObjectName, TextXL, YL); bool bDrawFullOverHead = MyPawn != nullptr && GetDebuggingReplicator()->GetSelectedActorToDebug() == MyPawn; float IconXLocation = OverHeadContext.DefaultX; float IconYLocation = OverHeadContext.DefaultY; if (bDrawFullOverHead) { OverHeadContext.DefaultX -= (0.5f*TextXL*FontScale.X); OverHeadContext.DefaultY -= (1.2f*YL*FontScale.Y); IconYLocation = OverHeadContext.DefaultY; OverHeadContext.CursorX = OverHeadContext.DefaultX; OverHeadContext.CursorY = OverHeadContext.DefaultY; } if (DebugComponent->DebugIcon.Len() > 0) { UTexture2D* RegularIcon = (UTexture2D*)StaticLoadObject(UTexture2D::StaticClass(), NULL, *DebugComponent->DebugIcon, NULL, LOAD_NoWarn | LOAD_Quiet, NULL); if (RegularIcon) { FCanvasIcon Icon = UCanvas::MakeIcon(RegularIcon); if (Icon.Texture) { const float DesiredIconSize = bDrawFullOverHead ? 32.f : 16.f; DrawIcon(OverHeadContext, FColor::White, Icon, IconXLocation, IconYLocation - DesiredIconSize, DesiredIconSize / Icon.Texture->GetSurfaceWidth()); } } } if (bDrawFullOverHead) { OverHeadContext.FontRenderInfo.bEnableShadow = bDrawFullOverHead; PrintString(OverHeadContext, bDrawFullOverHead ? FColor::White : FColor(255, 255, 255, 128), FString::Printf(TEXT("%s/n"), *ObjectName)); OverHeadContext.FontRenderInfo.bEnableShadow = false; } if (EngineShowFlags.DebugAI) { DrawPath(PC, DebugComponent); }#endif //!(UE_BUILD_SHIPPING || UE_BUILD_TEST)}
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:59,
示例13: GetAIControllerAAIController* UAIBlueprintHelperLibrary::GetAIController(AActor* ControlledActor){ APawn* AsPawn = Cast<APawn>(ControlledActor); if (AsPawn != nullptr) { return Cast<AAIController>(AsPawn->GetController()); } return Cast<AAIController>(ControlledActor);}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:9,
示例14: OwnerIsLocallyControlledbool FGameplayCueHandler::OwnerIsLocallyControlled() const{ APawn* Pawn = Cast<APawn>(Owner); if (Pawn) { return Pawn->IsLocallyControlled(); } return false;}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:10,
示例15: TryGetPawnOwnervoid UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds){ Super::NativeUpdateAnimation(DeltaSeconds); APawn* OwningPawn = TryGetPawnOwner(); if (OwningPawn) { Speed = OwningPawn->GetVelocity().Size(); }}
开发者ID:wahidshafique,项目名称:GAME2013,代码行数:10,
示例16: GetLocalPlayerOwnervoid AGameplayDebuggerReplicator::SelectTargetToDebug(){#if ENABLED_GAMEPLAY_DEBUGGER APlayerController* MyPC = DebugCameraController.IsValid() ? DebugCameraController.Get() : GetLocalPlayerOwner(); if (MyPC) { float bestAim = 0; FVector CamLocation; FRotator CamRotation; check(MyPC->PlayerCameraManager != nullptr); MyPC->PlayerCameraManager->GetCameraViewPoint(CamLocation, CamRotation); FVector FireDir = CamRotation.Vector(); UWorld* World = MyPC->GetWorld(); check(World); APawn* PossibleTarget = nullptr; for (FConstPawnIterator Iterator = World->GetPawnIterator(); Iterator; ++Iterator) { APawn* NewTarget = *Iterator; if (NewTarget == nullptr || NewTarget == MyPC->GetPawn() || (NewTarget->PlayerState != nullptr && NewTarget->PlayerState->bIsABot == false) || NewTarget->GetActorEnableCollision() == false) { continue; } if (NewTarget != MyPC->GetPawn()) { // look for best controlled pawn target const FVector AimDir = NewTarget->GetActorLocation() - CamLocation; float FireDist = AimDir.SizeSquared(); // only find targets which are < 25000 units away if (FireDist < 625000000.f) { FireDist = FMath::Sqrt(FireDist); float newAim = FVector::DotProduct(FireDir, AimDir); newAim = newAim / FireDist; if (newAim > bestAim) { PossibleTarget = NewTarget; bestAim = newAim; } } } } if (PossibleTarget != nullptr && PossibleTarget != LastSelectedActorToDebug) { ServerSetActorToDebug(Cast<AActor>(PossibleTarget)); } }#endif //ENABLED_GAMEPLAY_DEBUGGER}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:54,
示例17: GetOwnervoid 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); } }}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:54,
示例18: SetBase/** Change the Pawn's base. */void ACharacter::SetBase( UPrimitiveComponent* NewBaseComponent, bool bNotifyPawn ){ if (NewBaseComponent != MovementBase) { // Verify no recursion. APawn* Loop = (NewBaseComponent ? Cast<APawn>(NewBaseComponent->GetOwner()) : NULL); for( ; Loop!=NULL; Loop=Cast<APawn>(Loop->GetMovementBase()) ) { if( Loop == this ) { UE_LOG(LogCharacter, Warning, TEXT(" SetBase failed! Recursion detected. Pawn %s already based on %s."), *GetName(), *NewBaseComponent->GetName()); return; } } // Set base. MovementBase = NewBaseComponent; if (Role == ROLE_Authority) { // Update replicated value UE_LOG(LogCharacter, Verbose, TEXT("Setting base on server for '%s' to '%s'"), *GetName(), *GetFullNameSafe(NewBaseComponent)); RelativeMovement.MovementBase = NewBaseComponent; RelativeMovement.bServerHasBaseComponent = (NewBaseComponent != NULL); // Flag whether the server had a non-null base. } else { UE_LOG(LogCharacter, Verbose, TEXT("Setting base on CLIENT for '%s' to '%s'"), *GetName(), *GetFullNameSafe(NewBaseComponent)); } // Update relative location/rotation if ( Role == ROLE_Authority || Role == ROLE_AutonomousProxy ) { if (MovementBaseUtility::UseRelativePosition(MovementBase)) { RelativeMovement.Location = GetActorLocation() - MovementBase->GetComponentLocation(); RelativeMovement.Rotation = (FRotationMatrix(GetActorRotation()) * FRotationMatrix(MovementBase->GetComponentRotation()).GetTransposed()).Rotator(); } } // Notify this actor of his new floor. if ( bNotifyPawn ) { BaseChange(); } if (MovementBase && CharacterMovement) { // Update OldBaseLocation/Rotation as those were referring to a different base CharacterMovement->OldBaseLocation = MovementBase->GetComponentLocation(); CharacterMovement->OldBaseRotation = MovementBase->GetComponentRotation(); } }}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:55,
示例19: checkbool UPlayer::Exec( UWorld* InWorld, const TCHAR* Cmd,FOutputDevice& Ar){ if(PlayerController) { // Since UGameViewportClient calls Exec on UWorld, we only need to explicitly // call UWorld::Exec if we either have a null GEngine or a null ViewportClient UWorld* World = PlayerController->GetWorld(); check(World); check(InWorld == NULL || InWorld == World); const bool bWorldNeedsExec = GEngine == NULL || Cast<ULocalPlayer>(this) == NULL || static_cast<ULocalPlayer*>(this)->ViewportClient == NULL; APawn* PCPawn = PlayerController->GetPawnOrSpectator(); if( bWorldNeedsExec && World->Exec(World, Cmd,Ar) ) { return true; } else if( PlayerController->PlayerInput && PlayerController->PlayerInput->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( PlayerController->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( PCPawn && PCPawn->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( PlayerController->MyHUD && PlayerController->MyHUD->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( World->GetGameInstance() && World->GetGameInstance()->ProcessConsoleExec(Cmd, Ar, PCPawn) ) { return true; } else if( World->GetAuthGameMode() && World->GetAuthGameMode()->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( PlayerController->CheatManager && PlayerController->CheatManager->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if (World->GameState && World->GameState->ProcessConsoleExec(Cmd, Ar, PCPawn)) { return true; } else if (PlayerController->PlayerCameraManager && PlayerController->PlayerCameraManager->ProcessConsoleExec(Cmd, Ar, PCPawn)) { return true; } } return false;}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:54,
示例20: TickPathNavigationvoid 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++; } }}
开发者ID:MatzeOGH,项目名称:DonAINavigation,代码行数:53,
示例21: IsLocallyControlledbool FGameplayEffectContext::IsLocallyControlled() const{ APawn* Pawn = Cast<APawn>(Instigator.Get()); if (!Pawn) { Pawn = Cast<APawn>(EffectCauser.Get()); } if (Pawn) { return Pawn->IsLocallyControlled(); } return false;}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:13,
示例22: GetOwnervoid UPawnNoiseEmitterComponent::MakeNoise(AActor* NoiseMaker, float Loudness, const FVector& NoiseLocation){ if (!NoiseMaker || Loudness <= 0.f) { return; } // Get the Pawn that owns us, either directly or through a possible Controller owner. AActor* Owner = GetOwner(); APawn* PawnOwner = Cast<APawn>(Owner); if (PawnOwner == NULL) { AController* OwnerController = Cast<AController>(Owner); if (IsValid(OwnerController)) { PawnOwner = OwnerController->GetPawn(); } } // only emit sounds from pawns with controllers if (!IsValid(PawnOwner) || !PawnOwner->Controller) { return; } // Was this noise made locally by this pawn? if ( NoiseMaker == PawnOwner || ((PawnOwner->GetActorLocation() - NoiseLocation).SizeSquared() <= FMath::Square(PawnOwner->GetSimpleCollisionRadius())) ) { // use loudest noise within NoiseLifetime // Do not reset volume to zero after time has elapsed; sensors detecting the sound can choose for themselves how long to care about sounds. const bool bNoiseExpired = (GetWorld()->GetTimeSeconds() - LastLocalNoiseTime) > NoiseLifetime; if (bNoiseExpired || Loudness >= LastLocalNoiseVolume) { LastLocalNoiseVolume = Loudness; LastLocalNoiseTime = GetWorld()->GetTimeSeconds(); } } // noise is not local - use loudest in this period else { const bool bNoiseExpired = (GetWorld()->GetTimeSeconds() - LastRemoteNoiseTime) > NoiseLifetime; if (bNoiseExpired || Loudness >= LastRemoteNoiseVolume) { LastRemoteNoiseVolume = Loudness; LastRemoteNoisePosition = NoiseLocation; LastRemoteNoiseTime = GetWorld()->GetTimeSeconds(); } }}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:49,
示例23: GetAIControllerForActorAAIController* 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;}
开发者ID:WasPedro,项目名称:UnrealEngine4.11-HairWorks,代码行数:15,
示例24: FRotatorFExecStatus 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;}
开发者ID:Batname,项目名称:unrealcv,代码行数:16,
示例25: ue_py_checkPyObject *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;}
开发者ID:ckyun777,项目名称:UnrealEnginePython,代码行数:16,
示例26: GetBlackboardUBlackboardComponent* 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;}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:17,
示例27: checkvoid USoundNodeLocalPlayer::ParseNodes(FAudioDevice* AudioDevice, const UPTRINT NodeWaveInstanceHash, FActiveSound& ActiveSound, const FSoundParseParameters& ParseParams, TArray<FWaveInstance*>& WaveInstances){ // The accesses to the Pawn will be unsafe once we thread audio, deal with this at that point check(IsInGameThread()); AActor* SoundOwner = ActiveSound.AudioComponent.IsValid() ? ActiveSound.AudioComponent->GetOwner() : NULL; APlayerController* PCOwner = Cast<APlayerController>(SoundOwner); APawn* PawnOwner = (PCOwner ? PCOwner->GetPawn() : Cast<APawn>(SoundOwner)); const bool bLocallyControlled = PawnOwner && PawnOwner->IsLocallyControlled() && Cast<APlayerController>(PawnOwner->Controller); const int32 PlayIndex = bLocallyControlled ? 0 : 1; if (PlayIndex < ChildNodes.Num() && ChildNodes[PlayIndex]) { ChildNodes[PlayIndex]->ParseNodes(AudioDevice, GetNodeWaveInstanceHash(NodeWaveInstanceHash, ChildNodes[PlayIndex], PlayIndex), ActiveSound, ParseParams, WaveInstances); }}
开发者ID:nickgoku,项目名称:EpicSurvivalGameSeries,代码行数:17,
示例28: GetCameraPoseFExecStatus FCameraCommandHandler::GetCameraPose(const TArray<FString>& Args){ if (Args.Num() == 1) { bool bIsMatinee = false; FVector CameraLocation; FRotator CameraRotation; ACineCameraActor* CineCameraActor = nullptr; for (AActor* Actor : this->GetWorld()->GetCurrentLevel()->Actors) { // if (Actor && Actor->IsA(AMatineeActor::StaticClass())) // AMatineeActor is deprecated if (Actor && Actor->IsA(ACineCameraActor::StaticClass())) { bIsMatinee = true; CameraLocation = Actor->GetActorLocation(); CameraRotation = Actor->GetActorRotation(); break; } } if (!bIsMatinee) {// int32 CameraId = FCString::Atoi(*Args[0]); // TODO: Add support for multiple cameras // This should support multiple cameras// UGTCaptureComponent* CaptureComponent = FCaptureManager::Get().GetCamera(CameraId);// if (CaptureComponent == nullptr)// {// return FExecStatus::Error(FString::Printf(TEXT("Camera %d can not be found."), CameraId));// }// CameraLocation = CaptureComponent->GetComponentLocation();// CameraRotation = CaptureComponent->GetComponentRotation(); APawn* Pawn = FUE4CVServer::Get().GetPawn(); CameraLocation = Pawn->GetActorLocation(); CameraRotation = Pawn->GetControlRotation(); } FString Message = FString::Printf(TEXT("%.3f %.3f %.3f %.3f %.3f %.3f"), CameraLocation.X, CameraLocation.Y, CameraLocation.Z, CameraRotation.Pitch, CameraRotation.Yaw, CameraRotation.Roll); return FExecStatus::OK(Message); } return FExecStatus::Error("Number of arguments incorrect");}
开发者ID:Batname,项目名称:unrealcv,代码行数:46,
示例29: CollectDatavoid FGameplayDebuggerCategory_Navmesh::CollectData(APlayerController* OwnerPC, AActor* DebugActor){#if WITH_RECAST ARecastNavMesh* NavData = nullptr; APawn* PlayerPawn = OwnerPC ? OwnerPC->GetPawnOrSpectator() : nullptr; APawn* DebugActorAsPawn = Cast<APawn>(DebugActor); APawn* DestPawn = DebugActorAsPawn ? DebugActorAsPawn : PlayerPawn; if (DestPawn) { UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(OwnerPC->GetWorld()); const FNavAgentProperties& NavAgentProperties = DestPawn->GetNavAgentPropertiesRef(); NavData = Cast<ARecastNavMesh>(NavSys->GetNavDataForProps(NavAgentProperties)); } if (NavData) { // add 3x3 neighborhood of target const FVector TargetLocation = DestPawn->GetActorLocation(); TArray<int32> TileSet; int32 TileX = 0; int32 TileY = 0; const int32 DeltaX[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 }; const int32 DeltaY[] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 }; int32 TargetTileX = 0; int32 TargetTileY = 0; NavData->GetNavMeshTileXY(TargetLocation, TargetTileX, TargetTileY); for (int32 Idx = 0; Idx < ARRAY_COUNT(DeltaX); Idx++) { const int32 NeiX = TargetTileX + DeltaX[Idx]; const int32 NeiY = TargetTileY + DeltaY[Idx]; NavData->GetNavMeshTilesAt(NeiX, NeiY, TileSet); } const int32 DetailFlags = (1 << static_cast<int32>(ENavMeshDetailFlags::PolyEdges)) | (1 << static_cast<int32>(ENavMeshDetailFlags::FilledPolys)) | (1 << static_cast<int32>(ENavMeshDetailFlags::NavLinks)); NavmeshRenderData.GatherData(NavData, DetailFlags, TileSet); }#endif // WITH_RECAST}
开发者ID:WasPedro,项目名称:UnrealEngine4.11-HairWorks,代码行数:45,
示例30: CollectDataToReplicatevoid 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}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:45,
注:本文中的APawn类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ APlayerController类代码示例 C++ AP_SerialManager类代码示例 |