本文整理汇总了C++中UNavigationSystem类的典型用法代码示例。如果您正苦于以下问题:C++ UNavigationSystem类的具体用法?C++ UNavigationSystem怎么用?C++ UNavigationSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UNavigationSystem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetHitPosition
FVector ABaseController::GetHitPosition()
{
FNavLocation location;
UNavigationSystem* navSys = UNavigationSystem::GetCurrent(World);
navSys->GetRandomPointInNavigableRadius(AttackLocation, 200.f, location);
return location.Location;
}
开发者ID:destriu,项目名称:Extinction_SourceControl,代码行数:7,代码来源:BaseController.cpp
示例2: GetNewWanderPosition
FVector ABaseController::GetNewWanderPosition()
{
FNavLocation Location;
UNavigationSystem* NavSys = World->GetNavigationSystem();
FHitResult hit(ForceInit);
FCollisionQueryParams traceParams = FCollisionQueryParams(FName(TEXT("RV_Trace")), true, Self);
traceParams.bTraceComplex = true;
traceParams.bTraceAsyncScene = true;
int times = 0;
float minimuimDist = Self->MinimuimDistanceBetweenWanderLocations;
do{
if (times >= 50)
{
times = 0;
minimuimDist -= 500.f;
}
times++;
NavSys->GetRandomPointInNavigableRadius(Self->GetActorLocation(), Self->SightRange, Location);
} while (FVector::Dist(Location.Location, Self->GetActorLocation()) < minimuimDist);
bool bHit = World->LineTraceSingleByChannel(hit, Self->EyeLocation, Location.Location, ECC_Visibility, traceParams);
return Location.Location;
}
开发者ID:destriu,项目名称:Extinction_SourceControl,代码行数:28,代码来源:BaseController.cpp
示例3: GetNewSearchPosition
FVector ABaseController::GetNewSearchPosition()
{
FNavLocation Location;
UNavigationSystem* NavSys = World->GetNavigationSystem();
NavSys->GetRandomPointInNavigableRadius(TargetsLastKnownPosition, Self->SearchRange, Location);
return Location.Location;
}
开发者ID:destriu,项目名称:Extinction_SourceControl,代码行数:7,代码来源:BaseController.cpp
示例4: PostEditChangeProperty
void ANavLinkProxy::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
bool bUpdateInNavOctree = false;
if (PropertyChangedEvent.Property && PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(ANavLinkProxy, bSmartLinkIsRelevant))
{
SmartLinkComp->SetNavigationRelevancy(bSmartLinkIsRelevant);
bUpdateInNavOctree = true;
}
const FName CategoryName = FObjectEditorUtils::GetCategoryFName(PropertyChangedEvent.Property);
const FName MemberCategoryName = FObjectEditorUtils::GetCategoryFName(PropertyChangedEvent.MemberProperty);
if (CategoryName == TEXT("SimpleLink") || MemberCategoryName == TEXT("SimpleLink"))
{
bUpdateInNavOctree = true;
}
if (bUpdateInNavOctree)
{
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
if (NavSys)
{
NavSys->UpdateActorInNavOctree(*this);
}
}
Super::PostEditChangeProperty(PropertyChangedEvent);
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:27,代码来源:NavLinkProxy.cpp
示例5: RequestPathAndMove
FAIRequestID AAIController::RequestPathAndMove(FPathFindingQuery& Query, AActor* Goal, float AcceptanceRadius, bool bStopOnOverlap, FCustomMoveSharedPtr CustomData)
{
FAIRequestID RequestID;
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
if (NavSys)
{
FPathFindingResult PathResult = NavSys->FindPathSync(Query);
if (PathResult.Result != ENavigationQueryResult::Error)
{
if (PathResult.IsSuccessful() && PathResult.Path.IsValid())
{
if (Goal)
{
PathResult.Path->SetGoalActorObservation(*Goal, 100.0f);
}
PathResult.Path->EnableRecalculationOnInvalidation(true);
}
RequestID = RequestMove(PathResult.Path, Goal, AcceptanceRadius, bStopOnOverlap, CustomData);
}
else
{
UE_VLOG(this, LogBehaviorTree, Error, TEXT("Trying to find path to %s resulted in Error"), *GetNameSafe(Goal));
}
}
return RequestID;
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:30,代码来源:AIController.cpp
示例6: if
FORCENOINLINE
#endif // NAVSYS_DEBUG
void FNavigationOctreeSemantics::SetElementId(const FNavigationOctreeElement& Element, FOctreeElementId Id)
{
UWorld* World = NULL;
UObject* ElementOwner = Element.GetOwner();
if (AActor* Actor = Cast<AActor>(ElementOwner))
{
World = Actor->GetWorld();
}
else if (UActorComponent* AC = Cast<UActorComponent>(ElementOwner))
{
World = AC->GetWorld();
}
else if (ULevel* Level = Cast<ULevel>(ElementOwner))
{
World = Level->OwningWorld;
}
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(World);
if (NavSys)
{
NavSys->SetObjectsNavOctreeId(ElementOwner, Id);
}
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:26,代码来源:NavigationOctree.cpp
示例7: RequestPathAndMove
FAIRequestID AAIController::RequestPathAndMove(const FAIMoveRequest& MoveRequest, FPathFindingQuery& Query)
{
FAIRequestID RequestID;
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
if (NavSys)
{
FPathFindingResult PathResult = NavSys->FindPathSync(Query);
if (PathResult.Result != ENavigationQueryResult::Error)
{
if (PathResult.IsSuccessful() && PathResult.Path.IsValid())
{
if (MoveRequest.IsUsingPathfinding())
{
if (MoveRequest.HasGoalActor())
{
PathResult.Path->SetGoalActorObservation(*MoveRequest.GetGoalActor(), 100.0f);
}
PathResult.Path->EnableRecalculationOnInvalidation(true);
}
RequestID = RequestMove(MoveRequest, PathResult.Path);
}
}
else
{
UE_VLOG(this, LogAINavigation, Error, TEXT("Trying to find path to %s resulted in Error"), *GetNameSafe(MoveRequest.GetGoalActor()));
}
}
return RequestID;
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:33,代码来源:AIController.cpp
示例8: SCOPE_CYCLE_COUNTER
void AAIController::FindPathForMoveRequest(const FAIMoveRequest& MoveRequest, FPathFindingQuery& Query, FNavPathSharedPtr& OutPath) const
{
SCOPE_CYCLE_COUNTER(STAT_AI_Overall);
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
if (NavSys)
{
FPathFindingResult PathResult = NavSys->FindPathSync(Query);
if (PathResult.Result != ENavigationQueryResult::Error)
{
if (PathResult.IsSuccessful() && PathResult.Path.IsValid())
{
if (MoveRequest.IsMoveToActorRequest())
{
PathResult.Path->SetGoalActorObservation(*MoveRequest.GetGoalActor(), 100.0f);
}
PathResult.Path->EnableRecalculationOnInvalidation(true);
OutPath = PathResult.Path;
}
}
else
{
UE_VLOG(this, LogAINavigation, Error, TEXT("Trying to find path to %s resulted in Error")
, MoveRequest.IsMoveToActorRequest() ? *GetNameSafe(MoveRequest.GetGoalActor()) : *MoveRequest.GetGoalLocation().ToString());
UE_VLOG_SEGMENT(this, LogAINavigation, Error, GetPawn() ? GetPawn()->GetActorLocation() : FAISystem::InvalidLocation
, MoveRequest.GetGoalLocation(), FColor::Red, TEXT("Failed move to %s"), *GetNameSafe(MoveRequest.GetGoalActor()));
}
}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:30,代码来源:AIController.cpp
示例9: RebuildNavigation
void UCheatManager::RebuildNavigation()
{
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
if (NavSys)
{
NavSys->Build();
}
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:8,代码来源:CheatManager.cpp
示例10: GetWorld
void UNavLinkCustomComponent::SetDisabledArea(TSubclassOf<UNavArea> AreaClass)
{
DisabledAreaClass = AreaClass;
if (IsNavigationRelevant() && !bLinkEnabled && GetWorld() != nullptr )
{
UNavigationSystem* NavSys = GetWorld()->GetNavigationSystem();
NavSys->UpdateCustomLink(this);
}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:9,代码来源:NavLinkCustomComponent.cpp
示例11: ExecuteTask
// execution
EBTNodeResult::Type UAIE_GoToRandom_BTTaskNode::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) {
/* call super
* should aquire refrences for our BehaviorTreeComp, BlackboardComp, AIController, and BotCharacter
* will return EBTNodeResult::Succeeded if we have all of them
* will return EBTNodeResult::Failed if it failed to grab any of them
*/
EBTNodeResult::Type resultFromSuperExecution = Super::ExecuteTask(OwnerComp, NodeMemory);
// check that we successfully grabbed the BehaviorTreeComp, BlackboardComp, AIController, and BotCharacter
if (resultFromSuperExecution == EBTNodeResult::Succeeded) {
// check that we can get the World
if (GetWorld()) {
// get the current nav system from the world
UNavigationSystem* navSystem = UNavigationSystem::GetCurrent(GetWorld());
// check that we have a nav system
if (navSystem) {
// get our actors current location to pe used as our start position
FVector startPosi = BotCharacter->GetActorLocation();
// create a nav location to be used as our end position
// default will be set to our current position in case of failure to find a suitable end position
FNavLocation endPosi = FNavLocation(startPosi);
// attempt to get a random new position
if (navSystem->GetRandomReachablePointInRadius(startPosi, searchRadius, endPosi)) {
// if we were successfull in finding a new location get the MoveToLocation BlackboardKeyID
FBlackboard::FKey BlackboardKey_MoveToLocation = Blackboard->GetKeyID("MoveToLocation");
// check that we got the key
if ( Blackboard->IsValidKey( BlackboardKey_MoveToLocation)) {
// set the MoveToLocation BlackboardKeyID to our new location
Blackboard->SetValue<UBlackboardKeyType_Vector>(BlackboardKey_MoveToLocation, endPosi.Location);
// return succeeded now that we have set up our new loacation
return EBTNodeResult::Succeeded;
}
else {
// return Aborted if we can't find the Key as it will never succeed without a proper Key
if (bForceSuccess) {
return EBTNodeResult::Succeeded;
}
return EBTNodeResult::Aborted;
}
}
// return in progress if their are currently no valid locations
if (bForceSuccess) {
return EBTNodeResult::Succeeded;
}
return EBTNodeResult::InProgress;
}
}
}
// we will only get here if execution fails so we will check if force success is on
if (bForceSuccess) {
// if force success is on we will return Succeeded anyway
return EBTNodeResult::Succeeded;
}
// we want to return Failed after the force success check
return EBTNodeResult::Failed;
}
开发者ID:JDonDuncan,项目名称:AI_Example,代码行数:58,代码来源:AIE_GoToRandom_BTTaskNode.cpp
示例12: GetWorld
void USmartNavLinkComponent::SetDisabledArea(TSubclassOf<class UNavArea> AreaClass)
{
DisabledAreaClass = AreaClass;
if (IsNavigationRelevant() && !bLinkEnabled)
{
UNavigationSystem* NavSys = GetWorld()->GetNavigationSystem();
NavSys->UpdateSmartLink(this);
}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:9,代码来源:SmartNavLinkComponent.cpp
示例13: GetWorld
void UNavLinkCustomComponent::SetEnabledArea(TSubclassOf<class UNavArea> AreaClass)
{
EnabledAreaClass = AreaClass;
if (IsNavigationRelevant() && bLinkEnabled)
{
UNavigationSystem* NavSys = GetWorld()->GetNavigationSystem();
NavSys->UpdateCustomLink(this);
}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:9,代码来源:NavLinkCustomComponent.cpp
示例14: ServerCollectNavmeshData_Validate
bool UGameplayDebuggingComponent::ServerCollectNavmeshData_Validate(FVector_NetQuantize10 TargetLocation)
{
bool bIsValid = false;
#if WITH_RECAST
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
bIsValid = NavSys && NavSys->GetMainNavData(FNavigationSystem::DontCreate);
#endif
return bIsValid;
}
开发者ID:Art1stical,项目名称:AHRUnrealEngine,代码行数:10,代码来源:GameplayDebuggingComponent.cpp
示例15: GetWorld
void ANavigationTestingActor::SearchPathTo(ANavigationTestingActor* Goal)
{
#if WITH_EDITORONLY_DATA
if (EdRenderComp)
{
EdRenderComp->MarkRenderStateDirty();
}
#endif // WITH_EDITORONLY_DATA
if (Goal == NULL)
{
return;
}
UNavigationSystem* NavSys = GetWorld()->GetNavigationSystem();
check(NavSys);
const double StartTime = FPlatformTime::Seconds();
FPathFindingQuery Query = BuildPathFindingQuery(Goal);
EPathFindingMode::Type Mode = bUseHierarchicalPathfinding ? EPathFindingMode::Hierarchical : EPathFindingMode::Regular;
FPathFindingResult Result = NavSys->FindPathSync(NavAgentProps, Query, Mode);
const double EndTime = FPlatformTime::Seconds();
const float Duration = (EndTime - StartTime);
PathfindingTime = Duration * 1000000.0f; // in micro seconds [us]
bPathIsPartial = Result.IsPartial();
bPathExist = Result.IsSuccessful();
bPathSearchOutOfNodes = bPathExist ? Result.Path->DidSearchReachedLimit() : false;
LastPath = Result.Path;
PathCost = bPathExist ? Result.Path->GetCost() : 0.0f;
if (bPathExist)
{
LastPath->AddObserver(PathObserver);
if (OffsetFromCornersDistance > 0.0f)
{
((FNavMeshPath*)LastPath.Get())->OffsetFromCorners(OffsetFromCornersDistance);
}
}
#if WITH_RECAST && WITH_EDITORONLY_DATA
if (bGatherDetailedInfo && !bUseHierarchicalPathfinding)
{
ARecastNavMesh* RecastNavMesh = Cast<ARecastNavMesh>(MyNavData);
if (RecastNavMesh && RecastNavMesh->HasValidNavmesh())
{
PathfindingSteps = RecastNavMesh->DebugPathfinding(Query, DebugSteps);
}
}
#endif
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:53,代码来源:NavigationTestingActor.cpp
示例16: PostLoad
void ANavMeshBoundsVolume::PostLoad()
{
Super::PostLoad();
#if WITH_NAVIGATION_GENERATOR
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
if (NavSys && Role == ROLE_Authority)
{
NavSys->OnNavigationBoundsUpdated(this);
}
#endif
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:12,代码来源:NavMeshBoundsVolume.cpp
示例17: OnUnregister
void UNavLinkCustomComponent::OnUnregister()
{
Super::OnUnregister();
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
if (NavSys == NULL)
{
return;
}
// always try to unregister, even if not relevant right now
NavSys->UnregisterCustomLink(this);
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:13,代码来源:NavLinkCustomComponent.cpp
示例18: PostEditChangeProperty
void UNavigationQueryFilter::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
// remove cached filter settings from existing NavigationSystems
for (const FWorldContext& Context : GEngine->GetWorldContexts())
{
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(Context.World());
if (NavSys)
{
NavSys->ResetCachedFilter(GetClass());
}
}
}
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:14,代码来源:NavigationQueryFilter.cpp
示例19: PostEditChangeProperty
void ANavMeshBoundsVolume::PostEditChangeProperty( struct FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
#if WITH_NAVIGATION_GENERATOR
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
if (GIsEditor && NavSys)
{
if (PropertyChangedEvent.Property == NULL ||
PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(ABrush, BrushBuilder))
{
NavSys->OnNavigationBoundsUpdated(this);
}
}
#endif // WITH_NAVIGATION_GENERATOR
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:16,代码来源:NavMeshBoundsVolume.cpp
示例20: ExecuteTask
EBTNodeResult::Type UATBTTask_MoveArea::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
UNavigationSystem* NavigationSystem = UNavigationSystem::GetCurrent(GetWorld());
AATCharacterAI* MyCharacter = Cast<AATCharacterAI>(OwnerComp.GetAIOwner()->GetPawn());
if (NavigationSystem != nullptr && MyCharacter != nullptr)
{
FNavLocation RandomPointIn;
if (NavigationSystem->GetRandomPointInNavigableRadius(MyCharacter->GetActorLocation(), MyCharacter->AreaRadius, RandomPointIn))
{
OwnerComp.GetBlackboardComponent()->SetValue<UBlackboardKeyType_Vector>(GetSelectedBlackboardKey(), RandomPointIn.Location);
return EBTNodeResult::Succeeded;
}
}
return EBTNodeResult::Failed;
}
开发者ID:sshioi,项目名称:ATGame,代码行数:16,代码来源:ATBTTask_MoveArea.cpp
注:本文中的UNavigationSystem类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论