x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Find the point on navmesh closest to some FVector (not on navmesh)?

I'm building a world where AI controlled characters navigate to various locations, usually another Actor, and I ran into the issue where the goal Actor's location is occasionally not on the NavMesh. This is affecting my call to UNavigationSystem::SimpleMoveToActor() and UNavigationSystem::SimpleMoveToLocation().

How can I calculate a new FVector, one located on the navmesh which I can supply to SimpleMoveToLocation, so that my characters can move to the closest navigable point?

Product Version: Not Selected
Tags:
more ▼

asked Nov 22 '14 at 11:56 PM in C++ Programming

avatar image

saporter
15 1 2 4

avatar image jtarczykowski Jul 27 '17 at 01:09 PM

It's sad that docs are so bad on that topic and there is no proper answer. Anyway to figure it out I've looked at the source of GetRandomPointInNavigableRadius - and basically what I think would be the best approach is to get all NavPolys in are with GetPolysInBox method and then you can iterate on those Polys and find closest points.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

This could help you: https://answers.unrealengine.com/questions/139225/best-fast-method-to-detect-if-point-is-on-navmesh.html

You can manipulate with Extent argument to find point of navmesh in proximity of your target location.

Marcin

more ▼

answered Nov 27 '14 at 11:49 AM

avatar image

mpo
578 23 15 48

avatar image saporter Nov 28 '14 at 06:10 AM

That looked promising but it doesn't seem to "project" a point on to the NavMesh in the (x,y) plane. It seems to project a point in the sky onto the ground (z axis) just fine, but I need to be able to project a point completely out of bounds (but on the same plane) back into bounds. Here's how I was using it:

 FVector newGoalVector = UNavigationSystem::ProjectPointToNavigation(goalActor, goalActor->GetActorLocation());

Internally, it looks like this particular call was assigning an INVALID_NAVEXTENT value to Extent. No joy. Then I tried:

 UNavigationComponent* PFindComp = nullptr;
 UPathFollowingComponent* PFollowComp = nullptr;
 AActor* goal = citizen ? container->TargetGoal : nullptr;   // set goal.  Never null
 CitizenController->InitNavigationControl(PFindComp, PFollowComp);
 FVector Point = goal->GetActorLocation();
 FNavLocation ProjectedPoint(Point);
 UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GEngine->GetWorldFromContextObject(goal));
 NavSys->ProjectPointToNavigation(Point, ProjectedPoint, PFindComp->GetQueryExtent() , PFindComp->GetNavData(), PFindComp->GetStoredQueryFilter());

Same thing... Still doesn't project the way I need it to. I can't find a lot of documentation on Extent (or these functions or how to use them). Any further advice?

avatar image daren720 Jun 02 '17 at 08:35 PM

Were you able to resolve this? I'd like to be able to find the nearest point on a nav mesh from a point that is off the nav mesh - after determining that it is off the nav mesh.

thanks Daren

avatar image Nonlin Jul 23 '18 at 11:54 PM

Can't figure out how to use Project Point To Navigation either. Doesn't do what I thought and no docs on it.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question