1
\$\begingroup\$

I'm making generator for EQS and need to put points on navmeshes located on different heights, one above other. So, my idea is to make raycast vertically and find intersection points with navmeshes. But how to do it?

I tried to set CollisionResponseChannel to NavMeshBoundsVolume but all raycast hits happened on the edge of volume's box, not on navmesh.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

I found the function what does exactly what I need:

bool ARecastNavMesh::ProjectPointMulti(const FVector& Point, TArray<FNavLocation>& OutLocations, const FVector& Extent, float MinZ, float MaxZ, FSharedConstNavQueryFilter Filter, const UObject* QueryOwner) const 

There is the example of usage:

void UEnvQueryGenerator_VolumetricGrid::NavigationRaycast(TArray<FNavLocation>& Points, const FVector& Position, FEnvQueryInstance& QueryInstance) const { const UObject* Querier = QueryInstance.Owner.Get(); const ANavigationData* NavData = nullptr; NavData = FEQSHelpers::FindNavigationDataForQuery(QueryInstance); const ARecastNavMesh* NavMeshData = Cast<const ARecastNavMesh>(NavData); if (NavMeshData == nullptr || Querier == nullptr) { return; } FSharedConstNavQueryFilter NavigationFilter = UNavigationQueryFilter::GetQueryFilter(*NavData, Querier, ProjectionData.NavigationFilter); TArray<FNavLocation> HitLocations; const FVector ProjectionExtent(ProjectionData.ExtentX, ProjectionData.ExtentX, (ProjectionData.ProjectDown + ProjectionData.ProjectUp) / 2); NavMeshData->ProjectPointMulti(Position, HitLocations, ProjectionExtent, Position.Z - ProjectionData.ProjectDown, Position.Z + ProjectionData.ProjectUp, NavigationFilter, Querier); for (int32 HitIdx = 0; HitIdx < HitLocations.Num(); HitIdx++) { Points.Add(HitLocations[HitIdx]); } } 
\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.