How to make ai character to change path if player block its path

hello everyone, i have an AI character that follows my main character, and i have 2 doors. so if the main character block one of them and i gave the ai character an order to be in front of me (a target location in front of the main character) so the ai character take the path at the second door so it can move because the main character is blocking the first door.
Note: sorry i can not explain it very well so i added screenshot for what i mean.
Note 2: Ai character is trying to push main player to reach target location not picking the free path since ai character does not see the main character as an obstacle.

Your player must be a dynamic obstacle then. It’s in the capsule component details.
But I think it may interfere with the AI following the players, you’ll have to check it. Maybe you’ll have to toggle Dynamic Obstacle on and off depending on what the AI has to do.

it is enabled but Ai character is trying to push main player to reach target location not picking the free path (Dooor 2)

Here is something that may help
Navigation Modifiers

Any actor component that has collision can be setup to cut holes inside the navigation mesh.


To enable this feature, I created a new actor named NavigationBlocker.

This actor stops AI controlled actors from moving in the red area that the collision occupies.

Furthermore, the NavigationBlocker moves around the level, regenerating the navmesh to reflect the changed environment.

To keep it simple, this actor only has a Box Collision.

NavigationBlocker actor

Click the box collision component from the components list (shown above) and find the navigation category in the details panel on the left.

Tick the Dynamic Obstacle checkbox and set the area class to obstacle.

Navigation settings

Area Class

The area class determines how AI controlled actors will react to the modifier.

  • None will not affect the navigation.

  • Default will act like a normal area of navmesh.

  • LowHeight blocks all AI from navigating through it due to the height restriction.

  • Null blocks all navigation inside it.

  • Obstacle tells the AI that this area can be navigated through but only if there are no other possible ways to move to the target.

Example

The AI actor now dynamically adjusts to walk around the box.
image

1 Like

thanks for ur replay, i acutely did that earlier but sometimes the ai tries to take the short path that it does not fit him, so i thought it is not working. Do u think this issue happens because of agent radius value ? as shown in the second image.
i will appreatate it if u know how to solve this i even recreated the ai controller to use the detour crowd ai controller. And thanks in advance.
note: i mean he never try to go the other way or even try to enter the another door