This plugin allows characters in Unreal Engine to navigate 3D environments, detecting and avoiding obstacles dynamically, and finding the shortest 3D path to their target, whether in flying or walking mode.
-In future updates, this system will be compatible with my custom AI system and Behavior Tree framework, which I developed in Unreal Engine.
- Supported Versions
- Installation Instructions
- Workflow
- Features
- Architecture and Structure
- Dynamic Objects
- Blueprint and C++ Setup Examples
- Tutorial Video
- Potential Issues
This plugin is compatible with Unreal Engine 5.2 and later and is designed to work in both Blueprint and C++ projects.
-
Extract the Plugin File
Extract the downloaded.zip
file to a folder. -
Move the Plugin Folder
Move the extracted plugin folder to theEngine/Plugins/Marketplace
directory of your Unreal Engine installation. The path is usually:
C:\Program Files\Epic Games\UE_5.2\Engine\Plugins\Marketplace
-
Activate the Plugin
Open Unreal Engine, go toEdit > Plugins
, and enable the plugin.
AHVolume3D divides the volume into grids, marking each as full or empty for efficient pathfinding calculations.
AHPathCore uses A* to find the shortest path, recalculating in real-time when obstacles appear.
This plugin allows both walking and flying modes, customized through Character Movement Component.This makes it easy to adjust parameters such as speed, acceleration, and movement style.
- Walking Mode: Moves character along same-level grids, navigating small obstacles and sloped surfaces.
- Flying Mode: The character can freely move in all directions within the 3D space, with no vertical limitations.
-
Dynamic Obstacle Detection: The character detects nearby objects with DinamicObjectComponent and dynamically adjusts its route to avoid obstacles. This feature ensures smooth navigation, even in environments with moving obstacles.
-
Real-time Path Updates: The A algorithm* recalculates the route in real-time if new obstacles appear in the path. Triggered by CheckAvailability from the DinamicObjectComponent, the character quickly adapts to environmental changes, maintaining the optimal route to the target.
-
Flexible Movement Modes: Supports both walking and flying modes.
-
Character Movement Component Integration: Parameters like speed, acceleration, and movement style are easily adjustable through Character Movement Component, allowing for custom movement settings for each mode.
-
Grid-based Volume Management: Efficiently manages grid-based paths.
-
Smooth Path Optimization: Reduces unnecessary nodes for smoother paths.
-
Alternative Target Selection: If the end location is occupied, the system automatically selects the nearest available grid within a specified range as the new endpoint, ensuring the character can reach an accessible location close to the original target.
This plugin uses a grid-based volume for pathfinding and employs an advanced A algorithm* and dynamic obstacle detection system. It enables characters to navigate to their target in both flying and walking modes.
-
Volume: RRepresents the grid-based volume where pathfinding operations are performed. The volume’s grids can be subdivided based on surrounding objects, marking each grid as not free or free.
-Draw Debug Grids from Player(varaible(bool)): When enabled, this variable visualizes grids around the player, showing nearby navigable areas for debugging purposes.
- Core: Calculates the shortest path to the target using the A* algorithm. When dynamic obstacles are detected and they are moving, the Core recalculates the path in real-time. It also smooths the path and selects an alternative nearby target if the original target is blocked.
-
MoveToComponent: Manages pathfinding requests and movement for the character. It uses Unreal Engine's Character Movement Component to ensure smooth navigation.
-TargetLocation(varaible(Vector)): Set the target location for the character to reach.
-Draw Debug Line(varaible(bool)): When enabled, this variable displays the path line from the character to the target, useful for visualizing the calculated path.
-Debug Line Duration(varaible(float)): Sets the duration (in seconds) for how long the debug line remains visible. A value of -1 makes the line persist indefinitely.
- DynamicObjectComponent: Used to classify dynamic objects and allows them to mark grids they occupy as either full or empty. It automatically updates the pathfinding algorithm when objects move.
Objects or actors with the DynamicObjectComponent affect the grids within the volume as they move. These objects update the status of grids they occupy, marking them as occupied or free based on their movement. To configure a dynamic object, follow these steps:
-
In Project Settings > Collision, create a Trace Channel named "Dynamicbject" with Default Response set to Ignore.
-
In the object's Collision Presets, set the DinamicObject channel to Block.
When configured, dynamic objects update grid status as they move. The pathfinding system adjusts routes in real-time based on these updates.
To move the character towards a target in Blueprint, call the HMoveTo
function with the following parameters: Target(HMoveToComponent)
, Actor Ref
, Volume Ref
, and Tolerance Ref(50 to walk and over 50 to fly)
.
In C++, follow these steps:
-
Declare Volume and MoveToComponent:
UPROPERTY(EditAnywhere, Category = "PathFinding") class AHVolume3D* VolumeRef; UPROPERTY(VisibleAnywhere, Category = "PathFinding") class UHMoveToComponent* HMoveToComponent;
-
Call
HMoveTo
Function inBeginPlay
:if(VolumeRef) { HMoveToComponent->HMoveTo(this, VolumeRef, 50.f); }
-
Set Module Dependencies: Add
"H3DPathfinding"
toBuild.cs
dependencies:PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput", "H3DPathfinding" });
- Issue with ThirdPerson Map: The plugin may encounter issues on the default ThirdPerson map. If you experience problems, try testing on a different map.