# Implementation of A\* algorithm in unreal engine

**URL:** <https://forums.unrealengine.com/t/implementation-of-a-algorithm-in-unreal-engine/2284113>\
**Category:** Programming & Scripting\
**Tags:** pathfinding, unreal-engine, CPP, Blueprint\
**Created:** [January 18, 2025, 5:28am UTC](https://forums.unrealengine.com/t/implementation-of-a-algorithm-in-unreal-engine/2284113 "2025-01-18T05:28:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Damien220](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/damien220/32/626350_2.png) [@Damien220](https://forums.unrealengine.com/u/Damien220)\
**Post date:** [January 18, 2025, 5:28am UTC](https://forums.unrealengine.com/t/implementation-of-a-algorithm-in-unreal-engine/2284113/1 "2025-01-18T05:28:39Z")

</div>

Hey everyone,

I would like to share with you my implementation of A\* algorithm for path finding in unreal engine.

I used unreal engine 4.27 version.

[AStarUnreal](https://github.com/damien220/AStarUnreal)

I would really appreciate trying the project, and any comment on this project.

I still haven’t implemented any readme for the repo. i will later.

I am thinking about making a feature ( like a skill) for games using this technique (future work).

And thank you.

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [January 18, 2025, 5:19pm UTC](https://forums.unrealengine.com/t/implementation-of-a-algorithm-in-unreal-engine/2284113/2 "2025-01-18T17:19:17Z")

</div>

Found a minor flaw in your code. Loaded up the project and started the level, then ejected the player and started dragging the red ball around until I hit a wall. This triggered a nullptr exception.

Tracking any type of actor that could go passed player restrictive boundaries could be a problem

In pathfinder.cpp I added in a modification to counteract this problem, basically the EndNode would be null triggering a cascade of errors. In the case of it not being viable, I set the EndNode to the StartNode and the path finding resolves correctly once the obstructions are gone.

Added lines 40 =\> 42

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/8/eb824cf3a1a71da43bd351ee164f57a8731ac17c.png)

Revised file  
[Pathfinder.cpp](https://forums.unrealengine.com/uploads/short-url/fAyEECu2xF9v5yKzhKtWi2hEhGr.cpp) (4.9 KB)

---

<div class="post-metadata">

**Author:** ![Damien220](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/damien220/32/626350_2.png) [@Damien220](https://forums.unrealengine.com/u/Damien220)\
**Post date:** [January 19, 2025, 4:19pm UTC](https://forums.unrealengine.com/t/implementation-of-a-algorithm-in-unreal-engine/2284113/3 "2025-01-19T16:19:33Z")

</div>

Nice, thank you very much for finding this flaw. I will try to fix it as i didn’t try what you mentioned.
