https://github.com/haktan313/h3dpathfinding
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.
https://github.com/haktan313/h3dpathfinding
gamedevelopment gameplay pathfinding unreal-engine unreal-engine-5 unrealengine-ai
Last synced: about 1 month ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/haktan313/h3dpathfinding
- Owner: haktan313
- Created: 2024-11-11T14:51:44.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-01-31T00:13:26.000Z (4 months ago)
- Last Synced: 2025-03-27T13:38:48.785Z (about 2 months ago)
- Topics: gamedevelopment, gameplay, pathfinding, unreal-engine, unreal-engine-5, unrealengine-ai
- Language: C++
- Homepage:
- Size: 52.9 MB
- Stars: 12
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# H3DPathfinding
# H3DPathfinding Plugin Documentation
## Introduction
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.
## Contents
- [Supported Versions](#supported-versions)
- [Installation Instructions](#installation-instructions)
- [Workflow](#workflow)
- [1. Volume and Grid Division](#1-volume-and-grid-division)
- [2. Pathfinding and Obstacle Detection](#2-pathfinding-and-obstacle-detection)
- [3. Movement Modes](#3-movement-modes)
- [Features](#features)
- [Architecture and Structure](#architecture-and-structure)
- [Core Components](#core-components)
- [Dynamic Objects](#dynamic-objects)
- [Blueprint and C++ Setup Examples](#blueprint-and-c-setup-examples)
- [Tutorial Video](#tutorial-video)
- [Potential Issues](#potential-issues)## Supported Versions
This plugin is compatible with Unreal Engine 5.2 and later and is designed to work in both Blueprint and C++ projects.## Installation Instructions
1. **Extract the Plugin File**
Extract the downloaded `.zip` file to a folder.2. **Move the Plugin Folder**
Move the extracted plugin folder to the `Engine/Plugins/Marketplace` directory of your Unreal Engine installation. The path is usually:
`C:\Program Files\Epic Games\UE_5.2\Engine\Plugins\Marketplace`3. **Activate the Plugin**
Open Unreal Engine, go to `Edit > Plugins`, and enable the plugin.## Workflow

### 1. Volume and Grid Division
**AHVolume3D** divides the volume into grids, marking each as full or empty for efficient pathfinding calculations.
### 2. Pathfinding and Obstacle Detection
**AHPathCore** uses A* to find the shortest path, recalculating in real-time when obstacles appear.### 3. Movement Modes 
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.## Features
- **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.
## Architecture and Structure
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.
### Core Components

- **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.### Dynamic Objects
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:1. Ensure the object has a **DynamicObjectComponent**. 
2. Set **Mobility** to **Movable**.
3. In **Project Settings > Collision**, create a **Trace Channel** named "Dynamicbject" with **Default Response** set to **Ignore**.
4. In the object's **Collision Presets**, set the DinamicObject channel to **Block**.
5. Enable **Generate Overlap Events** for the object.
When configured, dynamic objects update grid status as they move. The pathfinding system adjusts routes in real-time based on these updates.
## Blueprint and C++ Setup Examples
### Blueprint Usage
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)`.
### C++ Usage
In C++, follow these steps:1. **Declare Volume and MoveToComponent**:
```cpp
UPROPERTY(EditAnywhere, Category = "PathFinding")
class AHVolume3D* VolumeRef;UPROPERTY(VisibleAnywhere, Category = "PathFinding")
class UHMoveToComponent* HMoveToComponent;
```2. **Call `HMoveTo` Function in `BeginPlay`**:
```cpp
if(VolumeRef)
{
HMoveToComponent->HMoveTo(this, VolumeRef, 50.f);
}
```3. **Set Module Dependencies**:
Add `"H3DPathfinding"` to `Build.cs` dependencies:
```csharp
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput", "H3DPathfinding" });
```## Tutorial Video
[](https://www.youtube.com/watch?v=51_4N3GaQ9c)## Potential Issues
- **Issue with ThirdPerson Map**: The plugin may encounter issues on the default ThirdPerson map. If you experience problems, try testing on a different map.