Download

How to access NavArea in which is Character standing ?

Hello,

Do you know how can I access NavArea in which is currently character standing, please ? I can not find any reference to that.

Thank you very much for help

I found a function like this.

I don’t know if this works but it should


UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(OwnerComp);

Thank you very much for reply! Atleast somebody checked my thread :slight_smile: This one returns you reference to UNavigationSystem but I am looking for some function which will return UNavArea :slight_smile:

For any other guys who interest in same topic, you need to cast to ARecastNavMesh to get access to many powerful functions of navmesh.

https://answers.unrealengine.com/questions/108556/how-to-read-current-navarea-in-which-character-is.html#comment-109257-form

:heart:

You’re welcome Nonder!

Here is my reply posted in this thread for anyone who wants to see the solution immediately :slight_smile:


**Video Pic For You**

I am doing what you are asking in this picture below!

**The nav area closest to the AI unit is being highlighted as they move!**

Here's a gif of my AI using my custom Nav components finding a jumping path to its target using only C++, and a simple nav mesh volume in editor. There are no special helpers in the level! This was all calculated in C++ !

http://share.gifyoutube.com/ZGQn5M.gif

Code, FindNearestPoly

In my custom UPathFollowComponent I wrote the following:



    NavNodeRef UJoyPathFollowCompHighest::NavPoly_FindNearest(const FVector & Loc, const FVector & Extent)
    {
    	if(!MovementComp) return false;
    	//~~~~~~~~~~~~~~~~~~
    	
    	//Agent Properties
    	const FNavAgentProperties* AgentProperties = MovementComp->GetNavAgentProperties();
    	if(!AgentProperties) return false;
    	//~~~~~~~~~~~~~~~~~~
    	
    	const ANavigationData* NavData = (AgentProperties != NULL) ? GetNavDataForProps(*AgentProperties) : GetMainNavData(FNavigationSystem::DontCreate);
    	 
    	if (NavData == NULL)
    	{
    		NavData = GetMainNavData();
    	}
    	 
    	const ARecastNavMesh* NavMesh = Cast<ARecastNavMesh>(NavData);
    	if(!NavMesh)
    	{
    		ScreenMsg("UJoyPathFollowCompHighest::DrawNavTileBounds()>> Cast to recast nav mesh failed");
    		return false;
    	}
    	
    	return NavMesh->FindNearestPoly(Loc,Extent,NavData->GetDefaultQueryFilter());
    }



**Recast**

The focus of my code is that I had to cast the basic nav mesh ptr to **ARecastNavMesh** in order to access the desired function

:)

**
Extent**

This determines how far above and below the point UE4 checks to find a valid nav area.

Enjoy!

Rama