How to use AreaClass in a collision component?

In 4.8 there is a new attribute “NavArea” in collision box component. I thought that it would enable a nav area like nav modifier volume does but it doesn’t seems to work. My setup is like that:

NavArea_Privacy should have different color but it doesn’t seems to work at all. It also has no influence on paths. I tried to check dynamic obstacle, the result is the same. What’s am I doing wrong?

(On the left there is a nav modified volume with the same class, working as expected.)

PS: Before 4.8 I had my own nav modifer box component, but it does not work properly anymore in 4.8

UNavBoxComponent::UNavBoxComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	NavAreaClass = UNavArea_Null::StaticClass();
	bCanEverAffectNavigation = true;
	bNavigationRelevant = true;
	bHasCustomNavigableGeometry = EHasCustomNavigableGeometry::EvenIfNotCollidable;
	SetCollisionEnabled(ECollisionEnabled::NoCollision);
	CanCharacterStepUpOn = ECB_No;
}

void UNavBoxComponent::GetNavigationData(FNavigationRelevantData &Data) const
{
	
	//UE_LOG(LogResto, Log, TEXT("GetNavigationData"));
	Data.Modifiers.Add(FAreaNavModifier(BoxExtent, GetComponentToWorld(), NavAreaClass));
}

In addition to specifying a nav area class you need to mark it as “Dynamic Obstacle”.

Cheers,

–mieszko

Hi Mieszko,

I tried this, same thing:

47015-navmod4.jpg

I just tried this in a clean 3rd person template from 4.8 and it doesn’t work either.

It seems you’ve nailed a bug down for us :slight_smile: I’ve just fixed it.

A workaround is to mark the shape component as colliding, like BlockAll. This should not matter for navmesh generation since it should still be used as dynamic obstacle. But it would still be the “block all” for other physics querying purposes - not sure you’re ok with that. Other collision presets should work as well (blocking pawns is what matters the most).

Thanks!
The workaround works for me, except that I had to ignore collision with pawns. After that I tried to see which collisions are important and it seems that only Vehicle collision is required, which is funny. Setup like that works fine:

Another thing I noticed is that sometimes, quite often, my bots started to get stuck in the navmesh. Namely, places where navmesh borders and area borders crosses, like places with X in this pic:

I hadn’t had this before with my own little nav box implementation.

From the screenshot it seems that AI agents’ collision radius is more than Agent Radius used for navmesh generations. Is that the case?

So, I just double-checked this.

Navigation Mesh-> Agent Radius : 5.0

Navigation System → supported Agents [0] → Nav Agent Radius: 5.0

RecastNavMesh-Default → Agent Radius : 5.0

Bot capsule radius: 5.0

Cell size: 5.0

Are there other places to look?

Also, If I set nav modifier area cube to no collision it doesn’t get stuck at all.

I found why it is happening. In fact, in the past I changed Crowd parameters. I’ve set Velocity Bias to 1.0 and it worked pretty well. Now in 4.8 this seems to cause problems. Agents get stuck even without nav areas. I’ve set it back to 0.5 and it works, nobody is stuck anymore.

The problem I have now, that every time an agent approaches the border of the navmesh it starts to “oscillate”, changing its yaw very quickly. That doesn’t look nice and also it slows down all moveto commands. When Velocity Bias is set to 1 agents move much more smoothly, but now in 4.8 they get stuck.

I couldn’t find any docs on Avoidance Config, are there some? I don’t realy understand what those parameters are doing, maybe there is another way to solve the “oscillation” problem?

Also, in our game we have a lot of furniture that player or bots can move, like those tables and chairs on screeenshot. We have normal collision on them, so we have holes in the navmesh. Would it be better to put dynamic nav areas of type obstacle instead?

edit: replacing normal collision with nav area obstacles made things worse, agents stuck even with velocity bias of 0.5

Well, finally I got it. Velocity Bias 0.75 did the trick. Still I would like to understand what am I doing…

Navmesh stress testing: Crazy Resto Sim: Testing Navmesh - YouTube

Still, they sometimes get stuck in unexpected ways, like at the end of the video, I moved a table and bots get stuck elsewhere.