# 's Multi-Threaded Dynamic Pathing System, Full Physics Support

**URL:** <https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510>\
**Category:** Game Development\
**Tags:** unreal-engine\
**Created:** [July 30, 2014, 8:52pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510 "2014-07-30T20:52:04Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [March 25, 2015, 11:53am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/122 "2015-03-25T11:53:39Z")

</div>

**AI Jumping To Reach Goals**

/8tu-XFTX6SQ

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [March 26, 2015, 4:39am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/123 "2015-03-26T04:39:48Z")

</div>

**Training PhysX Characters to navigate narrow ledges!**

In video I trained my Physics-simulating AI units to stay on narrow ledges!

My final algorithm to do what you see in video ended up being only about 3 lines of code!

I show **before** and **after** video segments so you see what I achieved!

**I did all of with a C++ custom UE4 path following component, using the UE4 navigation system.**

```auto

**My Goals**

**Goal 1:** To enable PhysX-simulating characters to use UE4 Navigation system

**Goal 2:** To enable such PhysX-simulating characters to not fall off of every ledge as they try to path along narrow ledges to get to the player, without cheating / using Editor helpers or making it look artificial/clunky! The final movement still needs to look natural and PhysX-y !

**All goals achieved by end of video!**

https://youtube.com/d7mAhStMABo

Enjoy the video!

PS: Yes I did say **PhysX-y**! You know what I am talking about!
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_726485b2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_726485b2](https://forums.unrealengine.com/u/anonymous_user_726485b2)\
**Post date:** [March 26, 2015, 2:05pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/124 "2015-03-26T14:05:17Z")

</div>

Wow is some awesome stuff! \<3

---

<div class="post-metadata">

**Author:** ![SE\_JonF](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/se_jonf/32/958477_2.png) [@SE\_JonF](https://forums.unrealengine.com/u/SE_JonF)\
**Post date:** [March 26, 2015, 3:56pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/125 "2015-03-26T15:56:47Z")

</div>

Been a while since I’ve had a to check out your works, awesome as always . Keep it up! =)

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [March 27, 2015, 12:15am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/126 "2015-03-27T00:15:41Z")

</div>

> [@CosmicGiant;257388](#):
>
> Wow is some awesome stuff! \<3

Hee hee! great to hear from you CosmicGiant!

> [@SE\_JonF;257475](#):
>
> Been a while since I’ve had a to check out your works, awesome as always . Keep it up! =)

Thanks SE\_JonF!

```auto

**Featured on Epic Twitch Stream Today**

**Epic Twitch Stream Link**
/b/641812681

Have fun today !

https://www.mediafire.com/convkey/a416/xh2a0w6qocsc9xb6g.jpg
```

---

<div class="post-metadata">

**Author:** ![TAN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TAN](https://forums.unrealengine.com/u/TAN)\
**Post date:** [March 29, 2015, 9:17pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/127 "2015-03-29T21:17:46Z")

</div>

![56ea31df16c7301ec4e385019dadc9711ebacf87.jpeg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/e/56ea31df16c7301ec4e385019dadc9711ebacf87.jpeg)

Great endeavor here.

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [March 30, 2015, 11:13am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/128 "2015-03-30T11:13:31Z")

</div>

**PhysX Simulating Characters Pathing Over Dynamically Generated Ledges!**

[https://youtube.com/DtTN52\_oTfQ](https://youtube.com/DtTN52_oTfQ)

In video you get to watch as I construct a section of level using my in-game level editor tools!

Then my physX-simulating ball characters are able to path over the ledges using the ledge-path AI I developed and demo in a prior video!

```auto

**In-Game Editor Tools**

Again video is a fun demonstration of my in-game editor tools that are used to build levels while the UE4 Editor is closed!

Watch my AI units easily path over and through these **runtime user-generated** sections of level!

```

**UE4 Nav Mesh Rebuild At Runtime**

**video shows off how good UE4 rebuild at runtime is** , as you watch the AI find my player unit amongst dynamically generated pieces of level that you watch me build during the video!

As I say in my conclusion to the video:

**Yay for UE4 Navigation Rebuild-At-Runtime!**

🙂

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [April 1, 2015, 7:48am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/129 "2015-04-01T07:48:02Z")

</div>

\*\*'s In-Game Level Editor

(bump of above video)\*\*

Enjoy!

[https://youtube.com/DtTN52\_oTfQ](https://youtube.com/DtTN52_oTfQ)

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [May 9, 2015, 8:32pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/131 "2015-05-09T20:32:56Z")

</div>

[https://youtube.com/sMMSQdnyt6o](https://youtube.com/sMMSQdnyt6o)

UE4 AI Pathing With Skeletal Meshes!

[Full description](https://forums.unrealengine.com/showthread.php?25410--s-Multi-Threaded-Dynamic-Pathing-System-Full-Physics-Support&p=251216&viewfull=1#post251216)

🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_dd205574](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_dd205574](https://forums.unrealengine.com/u/anonymous_user_dd205574)\
**Post date:** [May 23, 2015, 6:01am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/132 "2015-05-23T06:01:57Z")

</div>

Pretty darn nice. 🙂

---

<div class="post-metadata">

**Author:** ![Mr\_SquarePeg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mr\_SquarePeg](https://forums.unrealengine.com/u/Mr_SquarePeg)\
**Post date:** [May 23, 2015, 7:43am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/133 "2015-05-23T07:43:24Z")

</div>

is awesome !

Keep up the awesome work 😃

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [May 25, 2015, 9:19pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/134 "2015-05-25T21:19:05Z")

</div>

> [@Ariegos;297702](#):
>
> Pretty darn nice. 🙂

Hee hee! \* Blushes \*

> [@HeadClot;297722](#):
>
> is awesome !
> 
> Keep up the awesome work 😃

Thanks! Great to hear from you!

🙂

---

<div class="post-metadata">

**Author:** ![Cpt.Kittens](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cpt.Kittens](https://forums.unrealengine.com/u/Cpt.Kittens)\
**Post date:** [June 24, 2015, 10:14pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/135 "2015-06-24T22:14:28Z")

</div>

Any you could share some of the code for the jumping? ( I haven’t seen whether you have already or not )

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b90fa9e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b90fa9e](https://forums.unrealengine.com/u/anonymous_user_4b90fa9e)\
**Post date:** [June 28, 2015, 10:52pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/136 "2015-06-28T22:52:08Z")

</div>

Hey

Awesome work! I can’t tell you enough how many times your posts and answers scattered throughout the Unreal World, have helped steer me in the right direction on multiple occasions.

I have been trying to do a similar path finding jump as your videos above, but am getting stuck on one part, On your #140 comment , the video shows some dynamic path finding and jumps being made by the AI to get to the player. I have been looking at the Recast Nav mesh and am able to find the nearest poly and the get all polys methods you posted but the find nearest seems to only return a poly on the same area and the find all polys returns everything it seems. Is there a find nearest poly between two areas? I cant seem to find a query function that finds where the AI should start its path at, given the player being a couple jumps away. In your example video, I see you have two poly areas being highlighted the yellow ones that signal where the AI should move to and the green ones that signal where to jump to. Is it possible to shed some light on how to get those polys? I don’t care about sharing code as much as just an explanation of the idea you used, as I still want to learn for myself, just cant seem to figure out a way to accomplish that part.

Thanks !

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [August 4, 2015, 2:18pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/137 "2015-08-04T14:18:58Z")

</div>

> [@yesNinja;320682](#):
>
> Hey
> 
> Awesome work! I can’t tell you enough how many times your posts and answers scattered throughout the Unreal World, have helped steer me in the right direction on multiple occasions.

Yaay! I’m glad to have helped out!

> [@yesNinja;320682](#):
>
> Is it possible to shed some light on how to get those polys? I don’t care about sharing code as much as just an explanation of the idea you used, as I still want to learn for myself, just cant seem to figure out a way to accomplish that part.
> 
> Thanks !

That was actually the most complex part, I did a bunch of geometric tests to identify the proper points using **FBox** and **line tests**.

After obtaining the FBox that represents each poly, I then did a bunch of tests to see which one was the best for the unit to use 🙂

Here’s the function I created in my custom PathFollowingComponent to initiate my geometric tests:

```auto

//Verts
bool NavPoly_GetVerts(const NavNodeRef& PolyID, TArray<FVector>& OutVerts);

//Bounds
FBox NavPoly_GetBounds(const NavNodeRef& PolyID);

//Choose Which Nav Data To Use
FORCEINLINE const ANavigationData* JoyGetNavData() const
{
	const FNavAgentProperties& AgentProperties = MovementComp->GetNavAgentPropertiesRef() ;
	const ANavigationData* NavData = GetNavDataForProps(AgentProperties) ;
	if (NavData == NULL)
	{
		NavData = GetMainNavData();
	}
	   
	return NavData;
}

//~~~
bool UJoyPathFollowCompHighest::NavPoly_GetVerts(const NavNodeRef& PolyID, TArray<FVector>& OutVerts) 
{
	//Get Nav Data
	const ANavigationData* NavData = JoyGetNavData();
	 
	const ARecastNavMesh* NavMesh = Cast<ARecastNavMesh>(NavData);
	if(!NavMesh)
	{
		return false;
	}
	
	return NavMesh->GetPolyVerts(PolyID,OutVerts);
}

//Get Box of individual poly from verts
FBox UJoyPathFollowCompHighest::NavPoly_GetBounds(const NavNodeRef& PolyID)
{
	TArray<FVector> Verts;
	NavPoly_GetVerts(PolyID,Verts);
	
	FBox Bounds(0);
	for(const FVector& Each : Verts)
	{
		Bounds+=Verts;
	}
	
	return Bounds;
}

```

```auto

**Geometric Analysis Using FBox**

I had to do all the geometric analysis myself! 

I recommend you check out all the convenience functions in:

**UnrealMathUtility.h**

and

**Box.h**

These are the basic tools you can use to do the analysis yourself to find the best spot!

```

**Essential Function**

I especially recommend checking out a fast trace you can do using a Line Box intersection:

UnrealMathUtility.h

```auto

/** Determines whether a line intersects a box. */
static bool **LineBoxIntersection** ( const FBox& Box, const FVector& Start, const FVector& End, const FVector& Direction );

/** Determines whether a line intersects a box. overload avoids the need to do the reciprocal every time. */
static bool **LineBoxIntersection** ( const FBox& Box, const FVector& Start, const FVector& End, const FVector& Direction, const FVector& OneOverDirection );

/* Swept-Box vs Box test */
static CORE_API bool **LineExtentBoxIntersection** (const FBox& inBox, const FVector& Start, const FVector& End, const FVector& Extent, FVector& HitLocation, FVector& HitNormal, float& HitTime);

```

```auto

**Multi-Threading**

I multi-threaded my final solution to result in best performance.

```

Good Luck!

I look forward to hearing about your chosen implementation!

🙂

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [August 4, 2015, 2:19pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/138 "2015-08-04T14:19:40Z")

</div>

AI Dodge Wiki

Dear Community,

I’ve just posted a C++ wiki on implementing an AI Dodge mechanic!

In just a few lines of code I show you how you can tell an AI unit to dodge left or right, and how far, and also ensure the UE4 Navigation System will find the calculated dodge point using Nav Mesh Projection!

**AI Dodge Wiki**

> **[Wiki Code Tutorials](https://forums.unrealengine.com/showthread.php?299-Wiki-Code-Tutorials&p=348246&viewfull=1#post348246)**
>
> https://www.mediafire.com/convkey/7d2b/fr75kbso2kkazru6g.jpg Dear Community, I have been hard at work making UE4 C++ Code tutorials! I have added many pages of entirely code-focused tutorials, including both .h and .cpp, to the UE4 Wiki Code...

Enjoy!

---

<div class="post-metadata">

**Author:** ![MikeeVer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MikeeVer](https://forums.unrealengine.com/u/MikeeVer)\
**Post date:** [August 13, 2015, 2:54am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/139 "2015-08-13T02:54:49Z")

</div>

Hi  
Just want to know, you remake navigation system or add extra validation on unreal path finding system?  
is can be implementable to big landscape like open world game? because you got all polys…

🙂

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [October 6, 2015, 11:00am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/140 "2015-10-06T11:00:41Z")

</div>

> [@n0sam3;354426](#):
>
> Hi  
> Just want to know, you remake navigation system or add extra validation on unreal path finding system?  
> is can be implementable to big landscape like open world game? because you got all polys…
> 
> 🙂

I am using UE4 navigation system for my more recent jump pathing videos, I’ve also created my own navigation systems / nav mesh / AI path following, from scratch!

Epic has a nice way to stream in nav meshes, **and also nav meshes can be separated** , so that the lookup of all polys is local to the units nearest nav mesh, meaning I am not looking up all polys in the entire open world

🙂

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [November 9, 2015, 10:40am UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/141 "2015-11-09T10:40:40Z")

</div>

**'s Physics Character Pathing System**

**One of my favorite AI Victories!**

I overrode and rewrote large portions of Epic’s Character AI Pathing system to work with physics simulating characters!

There’s no native support for , but using some of my own functions that I’ve been writing for my physics multiplayer game, I was able to do it!

Epic very nicely exposed as virtual all the functions I needed to override, thank you Epic!

Here is the result!

[https://youtube.com/osC5GI\_t7Ic](https://youtube.com/osC5GI_t7Ic)

```auto

**PhysX Creature That Can Navigate the UE4 World ~ Evolution**

I then evolved system into my own game here:

https://youtube.com/d7mAhStMABo

```

**PhysX Creature Navigating In Dynamically Generated World**

core C++ coding research then enabled me to do what you see in video with my in-game level editor and some physx-simulating ball creatures!

[https://youtube.com/DtTN52\_oTfQ](https://youtube.com/DtTN52_oTfQ)

❤

---

<div class="post-metadata">

**Author:** ![knpc](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/knpc/32/1177131_2.png) [@knpc](https://forums.unrealengine.com/u/knpc)\
**Post date:** [November 9, 2015, 2:37pm UTC](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510/142 "2015-11-09T14:37:30Z")

</div>

Very awesome AI pathing projects thanks for sharing.

[Previous page](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510.md?page=6)

[Next page](https://forums.unrealengine.com/t/s-multi-threaded-dynamic-pathing-system-full-physics-support/8510.md?page=8)
