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):
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:
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?
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.