How do I constrain my AI to move at 90 degree angles ONLY

So I have some character BPs I’m moving about my level as AI Enemies (I’m using a nav mesh and scripting to tell them which target points I want them to go to.

HOWEVER, I want my AI to ONLY move at sharp 90 degree angles. How can I tell my AI when navigating through my maze of corridors to ONLY navigate at 90 degree angles? I don’t want them veering close to any wall. Once they pick which “hallway” to traverse down I just want them to shoot STRAIGHT down that hallway.

You can increase the size of the agent so that they don’t hit a wall.

A harder one would be to create your own pathfinding system that pathfinds points that are in line of sight of other so that your character only moves in 90 degree angle.

Thanks for your response. How does the “Nav Agent” on the CharacterMovement component within a Character BP work, exactly? Like I’m unsure of what it exactly does and how it affects my AI’s interactions with the world and the Nav Mesh.

Radius is the distance from unwalkable space, like the wall.

Each SupportedAgent will build their own NavMesh. You have to add SupportedAgent in the ProjectSettings->NavigationSystem. Adding a SupportedAgent radius of 100 will create a NavMesh that can support a NavAgent that with radius of 1 to 100. Adding again a SupportedAgent of 200 radius will support NavAgent with radius of 101 to 200.

  • If you set your CharacterMovement
    NavAgent radius to have a radius of
    50, it will use the NavMesh with
    radius of 100.
  • If you set your CharacterMovement
    NavAgent radius to have a radius of
    180, it will use the NavMesh with
    radius of 200.
  • If you set your CharacterMovement
    NavAgent radius to have a radius of
    250, it will use the NavMesh with
    radius of 200, this can cause the
    character to get blocked by walls if
    it really has a collision radius of
    250.

Also, you have to rebuild the NavMesh after adding SupportedAgent

Thanks for your response! I see now where this is in the Project Settings…

However, I’m still not getting things to work right. Please help me better understad!

  1. I’ve got “hallways” in my game that are 200uu wide
  2. My AI has a Capsule Component on it with a height of 96 and radius of 25
  3. My AI enemies have their Capsule Component Collision Preset set to “Spectator” (this is the only thing in this BP that has any sort of collision on it)

When I tried setting up any sort of “Support Agent” in the Navigation System Settings (I tried setting various radii…from 50, to 100, to 500) it caused my AI to not move at all.

Where am I failing with my setup? Are there other things I need to do or set up?