Changing Collision Component's Area Class to effect Navigation?

Hello,

I am having a few issue with using the “AreaClass” member of the UBoxComponent class, and wondered if anyone could help.

I have a class called MyABox which inherits from ATriggerBox. Within this class, i have created a function which simply modifies the area class of MyABox’s CollisionComponent. As a test, i have set the class to UNavArea_Null (no agent should be allowed to walk through the area):

91793-screen1.png

I can then compile my project and run it, however when i run the simulation in Unreal, my agents still freely able to walk though my box. Looking at the in editor display, i can see that the area class for my box has been set correctly:

91794-screen2.png

I’ve also made sure that my Navigation Mesh can update Dynamically, by changing the project settings:

I feel like i’m missing a certain step, like i’m not “giving” the information about my UBoxComponent and its AreaClass to the NavigationSystem, but i’m not sure exactly what i’m missing. Can anyone help me out with this issue?

EDIT: I think the problem is to do with me creating my AMyBox object dynamically at Runtime (im not placing it in the editor, im creating an instance of it via C++ at runtime). Is there something i need to additionally do?

You’re almost there. All that is missing is to set Dynamic Obstacle to true as well as Can Ever Affect Navigation if that’s not set.

Hi luthage,

I gave this a try but sadly no effect, i set the following two flags:

91802-u1screen2.png

Also i made sure those changes were being applied at runtime, and the Editor seems to indicate they have:

91803-u1screen1.png

When are you creating it? Mine works fine in the ctor.

What is the size of the box - you may need to adjust the extents to surround the trigger volume and hit the nav mesh.

Im creating AMyBox in a BeginPlay function in my game mode. What you describes works if i create a MyABox before starting the simulation, but not if i create it during my simulation.

The box is a good size, about one quarter of the of the NavigationMesh, so i dont think the size is the issue.

I’ve found a solution to this, as luthage stated the flags that needed to be set were the problem, however i had to set the flags during the Constructor of AMyBox rather than in a function that’s called later down the line.

You need to call OnRegister() if creating it out of the constructor. After you set up the navigation settings. That will register it with the navigation system.