NavMesh Settings to prevent AI from getting stuck?

Hey there,

i have a problem with my navigation. I am able to get the AI stuck on one side of a cube.

I have the standard settings in the NavMesh and just a normal Mesh or BSP placed.

http://puu.sh/gQimt/ff45361efd.jpg

The Agent Radius is 35 at the moment. The Player one is -1. I also played around with theses numbers. Small numbers, big numbers, big difference, 0 difference, etc. Nothing changes. As soon as a move on the other side of the cube, the AI tries to run through the Cube instead of moving around it.

http://puu.sh/gQitL/7285f786f1.jpg

What could i do about it?

EDIT: I am using “MoveTo” in the BehaviorTree, but it is still ignoring the cubes. If i am really far away from the AI, it still collides with these cubes instead of avoiding them.

It fells like it tries to go over the gap between the outer navmesh and that inner navmesh.

For Objects following I have to use a average radius of 250 to avoid issues with AI movement.

For Points you have to use cast to nav to avoid some issues.

This being said one thing i see above is that you may need to sink that wall into the floor more so the nav mesh does not cenerate inside your cube. As for corners I have asked this before and sharp corners can cause issues for AI as well as narow spacing. To rid myself of this I have a movement tracker to see how much im moving every tick and if im stuck for too long i scan for a clear point and use that as a waypoint between the stuck position and the destination area to help the AI free itsself. Also play with your grid sizes to make sure they are not too small. That can cause issues as well.

Thanks for the answer. I am doing most of this in C++. Only the “MoveTo” is used within the Behavior Tree.

http://puu.sh/gQn45/fe089e7277.png

If i use “EnemyPosition” which is the Actor Location of Enemy, it get really weird. He moves to the point where he found me and stays there instead of following me.

The C++ part is here:

/// Behavior Functions ///

void ABaseAIController::SearchEnemy()
{
	ABaseAIClass* MyPawn = Cast<ABaseAIClass>(GetPawn());

	if (MyPawn == NULL)
	{
		return;
	}

	const FVector BotLocation = MyPawn->GetActorLocation();

	float BestDistance = MAX_FLT;
	ASmallCoopTDCharacter* EnemyPawn = NULL;

	for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; ++It)
	{
		ASmallCoopTDCharacter* TempEnemyPawn = Cast<ASmallCoopTDCharacter>(*It);
		if (TempEnemyPawn)
		{
			const float Distance = FVector::Dist(TempEnemyPawn->GetActorLocation(), BotLocation);
			if (Distance < BestDistance)
			{
				BestDistance = Distance;
				EnemyPawn = TempEnemyPawn;
			}
		}
	}

	if (EnemyPawn && BestDistance <= MyPawn->GetBotConfig().SenseRange)
	{
		SetNewEnemy(EnemyPawn);
	}
}

void ABaseAIController::SetNewEnemy(class APawn* NewEnemy)
{
	BlackboardComp->SetValueAsObject(EnemyKeyID, NewEnemy);
	BlackboardComp->SetValueAsVector(EnemyLocationKeyID, NewEnemy->GetActorLocation());
}

That is just a simple “If we find an enemy withing range and he is the nearest, then set the BlackBoard values” algorithm. And in my Service, i just call the SearchEnemy() function.

Ok a quick edit:

I tried using the “MoveToActor” node that you did. I used in inside my cpp file. With this he uses the NavMesh. As soon as i am behind the wall, he tries to find a way around.

Is the “MoveTo” in the Tree broken or am i am using it wrong?

Could be that it does not use the nav mesh not 100% on that Id have to look back in my old answers when I had issues with it as well.

that maybe where ore logic has to come into play maybe that query system helps

I’m currently testing around.

He IS using the NavMesh in both situations. I just figured out, that if i stuck him for around 5 seconds behind this wall, he starts avoiding the block and runs around it to me.

But where do these 5 seconds come from? He should directly see that he is not following the navmesh and stop that.

I know on of the nods does a directly to actor straight line vs nav could be that nav is a back up if stuck is detected

Still he shouldn’t try to run through the wall. There is no NavMesh for him. And this only happens if i use “MoveTo” in the Behavior Tree. If i use “MoveToActor” in code, he uses the NavMesh more or less correctly.

Still hanging on corners sometimes, but i can’t really get him stuck behind a wall. It is important for me that the Player can’t stuck the NPCs…

Yes, MoveTo is the one that should use the NavMesh. The weird thing is, that “MoveToActor” (node or code doesn’t matter) works. It still gets stuck on those corner like you already showed, but it won’t run against the wall for around 5 seconds till it searches the real way.

So there must be a problem with the MoveTo Task. I could write my own Task that calls the MoveToActor function, but i would like to know where this comes from and if it is maybe just may fault.

I also heared there are a lot of bugs and fixes in the current engine releases. Maybe this is something related to my problem >.<

It sounds like the character isn’t using the navmesh at all. It definitely won’t try to go over the gap – that’s not how pathfinding on a navmesh works. Rather, it sounds like it’s just heading in a straight line, and blocked by the collision geometry. If you want to test this, you can rescale the cubes into thin walls (so there’s no interior mesh surfaces) and see if the character can get around them then.

As for why it’s not using the collision geometry… check for warnings from the navigation system in the output log. And make sure that the character height/radius matches the height/radius of one of the supported agent types in the navigation system options.

One thing you could try is delaying for a frame or two before you issue the MoveTo. It’s possible that initialization order issues are resulting in the pathfind being requested before the navmesh data is actually loaded into the world.

The thing is. If i wait a few seconds (while he is trying to run through the mesh) he starts running around it. I don’t know if there’s a hardcoded break for running against a wall for too long.

Would you mind telling me what navigation system options i need to look at?

Like i said, i have the Navigation Mesh on defaults. The values for radius and height of the Agent aren’t touched. The AI Agents are all -1 (changing these won’t have any influence). The capsule of the AI is the standard character capsule.

The weird thing is, that calling “MoveToActor” in Code works somehow.
Only this MoveTo is not working corretly.

Maybe i am not allowed to call it every frame, but normaly MoveTo should just skip the old MoveTo call if i recall it with a new position. I mean, he is walking to me and calling “MoveToActor” every frame is also working. I don’t know if the MoveTo is just broken here, because i read so many threads about a broken AI System at the moment. I would love to have Mieszko here to get some information :frowning: