14 if (GetCapsuleComponent())
19 VRRootReference->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
20 VRRootReference->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block);
24 if (GetMovementComponent())
53 FVector AgentLocation = FNavigationSystem::InvalidLocation;
55 if (GetCharacterMovement() !=
nullptr)
62 AgentLocation = GetCharacterMovement()->GetActorFeetLocation();
65 if (FNavigationSystem::IsValidLocation(AgentLocation) ==
false )
71 else if(GetCapsuleComponent() !=
nullptr)
72 AgentLocation = GetActorLocation() - FVector(0, 0, GetCapsuleComponent()->GetScaledCapsuleHalfHeight());
78void AVRCharacter::ExtendedSimpleMoveToLocation(
const FVector& GoalLocation,
float AcceptanceRadius,
bool bStopOnOverlap,
bool bUsePathfinding,
bool bProjectDestinationToNavigation,
bool bCanStrafe, TSubclassOf<UNavigationQueryFilter> FilterClass,
bool bAllowPartialPaths)
80 UNavigationSystemV1* NavSys =
Controller ? FNavigationSystem::GetCurrent<UNavigationSystemV1>(
Controller->GetWorld()) :
nullptr;
81 if (NavSys ==
nullptr ||
Controller ==
nullptr )
83 UE_LOG(LogVRCharacter,
Warning, TEXT(
"UVRCharacter::ExtendedSimpleMoveToLocation called for NavSys:%s Controller:%s (if any of these is None then there's your problem"),
84 *GetNameSafe(NavSys), *GetNameSafe(
Controller));
95 if (PFollowComp ==
nullptr)
97 PFollowComp = NewObject<UVRPathFollowingComponent>(
Controller);
98 PFollowComp->RegisterComponentWithWorld(
Controller->GetWorld());
99 PFollowComp->Initialize();
103 if (PFollowComp ==
nullptr)
105 UE_LOG(LogVRCharacter,
Warning, TEXT(
"ExtendedSimpleMoveToLocation - No PathFollowingComponent Found"));
109 if (!PFollowComp->IsPathFollowingAllowed())
111 UE_LOG(LogVRCharacter,
Warning, TEXT(
"ExtendedSimpleMoveToLocation - Path Following Movement Is Not Set To Allowed"));
115 EPathFollowingReachMode ReachMode;
117 ReachMode = EPathFollowingReachMode::OverlapAgent;
119 ReachMode = EPathFollowingReachMode::ExactLocation;
121 bool bAlreadyAtGoal =
false;
124 bAlreadyAtGoal = pathcomp->HasReached(GoalLocation, ReachMode);
126 bAlreadyAtGoal = PFollowComp->HasReached(GoalLocation, ReachMode);
129 if (PFollowComp->GetStatus() != EPathFollowingStatus::Idle)
131 if (GetNetMode() == ENetMode::NM_Client)
134 PFollowComp->AbortMove(*NavSys, FPathFollowingResultFlags::ForcedScript | FPathFollowingResultFlags::NewRequest
135 , FAIRequestID::AnyRequest, EPathFollowingVelocityMode::Reset );
139 PFollowComp->AbortMove(*NavSys, FPathFollowingResultFlags::ForcedScript | FPathFollowingResultFlags::NewRequest
140 , FAIRequestID::AnyRequest, bAlreadyAtGoal ? EPathFollowingVelocityMode::Reset : EPathFollowingVelocityMode::Keep);
146 PFollowComp->RequestMoveWithImmediateFinish(EPathFollowingResult::Success);
150 const ANavigationData* NavData = NavSys->GetNavDataForProps(
Controller->GetNavAgentPropertiesRef());
154 FPathFindingResult Result = NavSys->FindPathSync(Query);
155 if (Result.IsSuccessful())
157 FAIMoveRequest MoveReq(GoalLocation);
158 MoveReq.SetUsePathfinding(bUsePathfinding);
159 MoveReq.SetAllowPartialPath(bAllowPartialPaths);
160 MoveReq.SetProjectGoalLocation(bProjectDestinationToNavigation);
162 MoveReq.SetAcceptanceRadius(AcceptanceRadius);
163 MoveReq.SetReachTestIncludesAgentRadius(bStopOnOverlap);
164 MoveReq.SetCanStrafe(bCanStrafe);
165 MoveReq.SetReachTestIncludesGoalRadius(
true);
167 PFollowComp->RequestMove(MoveReq, Result.Path);
169 else if (PFollowComp->GetStatus() != EPathFollowingStatus::Idle)
171 PFollowComp->RequestMoveWithImmediateFinish(EPathFollowingResult::Invalid);
virtual void ExtendedSimpleMoveToLocation(const FVector &GoalLocation, float AcceptanceRadius=-1, bool bStopOnOverlap=false, bool bUsePathfinding=true, bool bProjectDestinationToNavigation=true, bool bCanStrafe=false, TSubclassOf< UNavigationQueryFilter > FilterClass=NULL, bool bAllowPartialPath=true) override
UFUNCTION(BlueprintCallable, Category = "VRBaseCharacter|Navigation", Meta = (AdvancedDisplay = "bSto...