Can't specify NavAgent with custom movement component

Hi all,

I’ve got a project going where I have primarily two types of pawns: Characters and Vehicles. I would prefer for the pawns to use the smaller default NavAgent, and for Vehicles to use the larger “Vehicle” NavAgent.

I tried specifying this in the project settings…


…And I tried specifying this within my custom movement component (including turning off Update Nav Agent with Owners Collision)…

However, I have had no luck. The vehicles still end up using the default navmesh instead of the vehicle one whenever I check using apostrophe.

You can see in the video the vehicle still ends up trying to use the stairs and go around corners too close, even though the vehicle navmesh does not show those as a possible path.

What gives? Any other leads on what could cause it to use the incorrect navmesh?

Hello,

You are dealing with a tricky issue! Here are a few suggestions that might help you resolve the problem:
Ensure Proper NavAgent Assignment: Double-check that your vehicles are correctly assigned the “Vehicle” NavAgent. You can do this by using the Set Nav Agent Props node in your vehicle’s movement component. This node allows you to override the default settings and specify the NavAgent properties directly.
Update Nav Agent with Owner’s Collision: Since you’ve already turned off “Update Nav Agent with Owner’s Collision,” make sure that the NavAgent properties are being set correctly in your custom movement component. Sometimes, the properties might not update as expected if there are conflicts or overrides elsewhere in your code.
Check NavMesh Bounds Volume: Ensure that your NavMesh bounds volumes are correctly set up and cover the areas where you want your vehicles to navigate. Sometimes, the NavMesh might not generate correctly if the bounds are not properly defined.
Debugging Pathfinding: Use the Show Navigation command in the console to visualize the NavMesh in your level. This can help you see if the NavMesh is being generated correctly for both the default and vehicle agents. Additionally, you can use the GetNavAgentLocation function to debug and ensure that your vehicles are using the correct NavAgent properties.
Custom Path Following Component: If the above steps don’t resolve the issue, consider creating a custom path-following component for your vehicles. This component can be costco com tailored to handle the specific navigation requirements of your vehicles, ensuring they follow the correct paths and avoid obstacles appropriately.

Hope that helps.

I noticed in the log this message keeps popping up whenever the agent is spawned. Anyone have some info on this? Google doesn’t seem to show any answers on this unfortunately.

LogNavigation: Warning: Looking for NavData using invalid FNavAgentProperties.

NavData is determined based on both radius and height of the agent. The check happens in ANavigationData* UNavigationSystemV1::GetNavDataForProps(), so you can debug that to see what’s going wrong.

The code also checks for valid properties (Radius and Height >= 0), which your actor doesn’t have, since you have -1 in height

If you don’t ever care about height, you can enable bSkipAgentHeightCheckWhenPickingNavData in your Navigation System project settings, in which case only the agent’s radius will matter

Thank you so much for the pointer. I’m not really sure of a good way to debug, but I did some digging until I found this.

const FNavAgentProperties& APawn::GetNavAgentPropertiesRef() const
{
	UPawnMovementComponent* MovementComponent = GetMovementComponent();
	return MovementComponent ? MovementComponent->GetNavAgentPropertiesRef() : FNavAgentProperties::DefaultProperties;
}

So it seems that when getting the NavData, it calls the Pawn’s function GetNavAgentPropertiesRef, which looks for a UPawnMovementComponent. My custom movement component was a UNavMovementComponent. You have to either override this function and return your custom movement component or make it so your movement component inherits from UPawnMovementComponent instead. I did the latter and now it’s properly selecting the NavAgent and using the corresponding RecastNavMesh.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.