Documentation for a Unreal Engine Plugin
To find all options in Detailspanel enter "PathFinder" into the Search when you opened the Blueprint.
CameraBase:
UnitBase:
PathProviderHUD:
https://www.unrealengine.com/marketplace/en-US/product/7a11e9225c414f94b7a5e19139a42e49
If you have downloaded the plugin it can be found in your Unreal Engine folder:
C:\Program Files\Epic Games\UE_5.0\Engine\Plugins\PathFinder (for example).
or
C:\Program Files\Epic Games\UE_5.0\Engine\Plugins\Marketplace\PathFinder
If you can find this folder in your enginge plugins folder the download was successful.
If the plugin is in another folder, you should copy it here.
Open Unreal Editor. Click Edit -> Plugins to open the plugin window.
Search for PathFinder and put a check mark at it.
For this Plugin you just have to Setup Viewport to Lock always and Setup the Enhanced Keyboard Settings.
Or Import "Input Backup 2023-03-27 100548 - Pathfinder" from
https://github.com/SilvanTeufel/Unreal_Plugin_Configs and Setup the Enhanced Keyboard Settings.
You can Change Inputs at: All\Engine\Plugins\PathFinder\Content\Blueprints\Controls
For GameplayTags you have to set AssetMangerClass in ProjectSettings (Restart Project after change):
Go to ProjectSettings->Input and set EnhancedIputComponentBase:
YOu can set MappingContext and ControlAsset in the BP_CameraBase:
Open Unreal Editor. Open folder (In Unreal Editor folder tab):
All\Engine\Plugins\PathFinder\Content\PathFinder\Level\levelOne
Your can find example Blueprints in the Unreal Editor as well:
All\Engine\Plugins\PathFinder\Content\PathFinder\Blueprints
This Blueprints use the Parent Classes from PathFinder Plugin, which you can use for your Blueprints.
The code snippet provided is written in C++ and utilizes the Unreal Engine. It appears to be a custom implementation of a Heads-Up Display (HUD) that allows the user to select friendly units by drawing a rectangle with their mouse. The code defines a DrawHUD() function for the AHUDBase class, which is responsible for rendering the HUD.
The DrawHUD() function performs the following steps:
The AHUDBase class is derived from the AHUD class in Unreal Engine. It is responsible for the graphical user interface and input handling for the player. The code provided includes a DrawHUD() function that is called every frame to update the HUD.
The class has the following methods:
AHUDBase::DrawHUD()
This method is called every frame to draw the HUD on the screen. It includes a selection rectangle that is drawn on the screen when the player selects friendly units.
AHUDBase::DeselectAllUnits()
This method deselects all the selected units.
AHUDBase::GetMousePos2D()
This method gets the current mouse position in 2D space.
AHUDBase::SelectAllUnits()
This method selects all the units.
AHUDBase::SetUnitSelected(AUnitBase* Unit)
This method sets a unit selected. It takes a unit as input and adds it to the selected units array.
AHUDBase::Tick()
This method is called every frame to update the state of the game. It is used to check for input and handle the selection of units.
void APathProviderHUD::BeginPlay()
This is a method that overrides the BeginPlay method of the AActor class. It is called when the actor is first spawned into the game world. In this implementation, the method gets all the actors of the AUnitBase class in the game world and populates arrays AllUnits, FriendlyUnits, and EnemyUnitBases with the results. It also gets all the actors of the ANoPathFindingArea class in the game world and populates the NoPathFindingAreas array with the results.
bool APathProviderHUD::IsLocationInNoPathFindingAreas(FVector Location)
This is a method that takes a FVector as an argument and returns a bool. It checks if the given location is inside any of the ANoPathFindingArea actors previously added to the NoPathFindingAreas array. If it is, it returns true, otherwise it returns false.
void APathProviderHUD::CreateGridsfromDataTable()
This is a method that populates the PathMatrixes array with FPathMatrix structures created from data in a GridDataTable. The GridDataTable must have been previously set.
void APathProviderHUD::CreateGridAndDijkstra()
This method populates the G_DijkstraPMatrixes array with FDijkstraMatrix structures created by running the Dijkstra algorithm on each of the PathMatrixes. It also associates each FDijkstraMatrix with a ADijkstraCenter actor in the game world. Both the PathMatrixes array and the ADijkstraCenter actors array must have been previously populated.
void APathProviderHUD::Tick(float DeltaSeconds)
This method overrides the Tick method of the AActor class. It is called every frame by the game engine. In this implementation, it updates a timer and when it reaches a certain value, it calls the CreateGridAndDijkstra method to populate the G_DijkstraPMatrixes array. It also calls other methods to move and patrol the friendly and enemy units through waypoints.
void APathProviderHUD::SetNextDijkstra(TArray<AUnitBase*> Units, float DeltaSeconds)
This method updates the Next_DijkstraPMatrixes field of each of the AUnitBase actors in the given Units array. The Next_DijkstraPMatrixes field is set to the FDijkstraMatrix in the G_DijkstraPMatrixes array that is closest to the AUnitBase actor in terms of Euclidean distance. The method does this by running a search of the G_DijkstraPMatrixes array for the closest one, and then updating the Next_DijkstraPMatrixes field of the AUnitBase actor accordingly. The method is called every SetNextDijkstraPauseTime seconds, as specified by the class member variable.
Note that the code contains additional helper methods such as CreatePathMatrix and Dijkstra that are not shown in the provided code snippet.
Here's a list of the properties (variables) in the APathProviderHUD
class and what they are used for:
TraceChannelProperty
: Used to specify the collision channel for the trace that the class performs.QueryParams
: Used to hold the parameters for a collision query.MaxCosts
: Maximum cost for a path in the Dijkstra algorithm.MaxDistance
: Maximum distance for a path in the Dijkstra algorithm.Debug
: Whether or not to show debug information in the HUD.StopLoading
: Whether or not to stop loading.DisablePathFindingOnEnemy
: Whether or not to disable pathfinding on enemy units.DisablePathFindingOnFriendly
: Whether or not to disable pathfinding on friendly units.PathMatrixes
: An array of FPathMatrix
structures.FoundCenterPoints
: An array of AActor
objects that represent the center points for the grid.GridDataTable
: A reference to a UDataTable
object that holds the data for the grid.CreatedGridAndDijkstra
: Whether or not the grid and Dijkstra algorithm have been created.SetNextDijkstraPauseTime
: The time to wait before the next Dijkstra algorithm is calculated in real-time.In addition, the class also has several functions that use these properties to perform various actions, such as creating the grid for Dijkstra, calculating Dijkstra in Begin_Play
, and handling the Dijkstra matrix.