# Binding to UPathFollowingComponent OnRequestFinished Event

**URL:** <https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698>\
**Category:** AI\
**Tags:** ai-navigation, compilation-error, unreal-engine, delegates, UE4, question, CPP\
**Created:** [April 23, 2019, 11:52am UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698 "2019-04-23T11:52:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Good\_Laugh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Good\_Laugh](https://forums.unrealengine.com/u/Good_Laugh)\
**Post date:** [April 23, 2019, 11:52am UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698/1 "2019-04-23T11:52:10Z")

</div>

So I’m trying to bind to UPathFollowingComponent::OnRequestFinished, it needs 2 arguments:

FAIRequestID , const FPathFollowingResult &.

**Here’s what I’ve done** :

In my header I forward declare the appropriate types, and declare my method to bind.

```
struct FAIRequestID;
struct FPathFollowingResult;

UFUNCTION()
void OnMoveCompleted(FAIRequestID RequestID, const FPathFollowingResult& Result);

```

In my cpp file, I include the appropriate headers, and bind the method in beginplay:

```
#include "AIController.h"
#include "Navigation/PathFollowingComponent.h" //Where FPathFollowingResult lives
#include "AITypes.h" //Where FAIRequestID lives

/* in begin play ...*/
AAIController* AI = Cast<AAIController>(GetController());
UPathFollowingComponent* PathFollowingComponent = AI->GetPathFollowingComponent();
if (AI)
{
	PathFollowingComponent->OnRequestFinished.AddUObject(this, &AFPSAIPatrolGuard::OnMoveCompleted);
}

```

**My Problem:**  
I keep getting the following compilation error:  
Unrecognized type ‘FPathFollowingResult’ - type must be a UCLASS, USTRUCT or UENUM.

EDIT:  
I’ve dug into FPathFollowingResult declaration in the source files, and it’s actually not marked with a USTRUCT(), so the error message is just stating the truth, but if that’s the case, then what IS the problem here?

**What I’ve tried:**  
EDIT: I’ve tried Including the headers in my header file and removing the forward declarations.

I spent 3 hours googling, and only thing that came up was this post:

> **[A way to override or bind OnMoveCompleted inside pawn class?](https://forums.unrealengine.com/questions/836104/a-way-to-override-or-bind-onmovecompleted-inside-p.html)**
>
> Is there way to override or bind to event aicontroller-\>onmovecompleted event inside pawn class?

I’m at lost here, anyone has an idea?

---

<div class="post-metadata">

**Author:** ![Lardo\_Deepdelver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lardo\_Deepdelver](https://forums.unrealengine.com/u/Lardo_Deepdelver)\
**Post date:** [April 23, 2019, 12:05pm UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698/2 "2019-04-23T12:05:03Z")

</div>

have you tried include the header for PathFollowingComponent.h in your AFPSAIPatrolGuard header

I had the experience that unreal code generation sometimes has problems with forward declarations.

---

<div class="post-metadata">

**Author:** ![Good\_Laugh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Good\_Laugh](https://forums.unrealengine.com/u/Good_Laugh)\
**Post date:** [April 23, 2019, 12:13pm UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698/3 "2019-04-23T12:13:26Z")

</div>

Thanks for the reply, tried it now, sadly it didn’t solve the problem: got the same error message.

---

<div class="post-metadata">

**Author:** ![phil\_me\_up](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@phil\_me\_up](https://forums.unrealengine.com/u/phil_me_up)\
**Post date:** [April 23, 2019, 1:32pm UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698/4 "2019-04-23T13:32:09Z")

</div>

What happens if you take  
#include “Navigation/PathFollowingComponent.h”  
out of the cpp and put it in the h, then remove the forward declaration?

You could introduce circular dependencies this way but it’s a quick fix to see if it resolves the issue.

---

<div class="post-metadata">

**Author:** ![Good\_Laugh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Good\_Laugh](https://forums.unrealengine.com/u/Good_Laugh)\
**Post date:** [April 23, 2019, 2:30pm UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698/5 "2019-04-23T14:30:51Z")

</div>

Same error ☹

I’ve checked FPathFollowingResult declaration in the source files, it’s actually not marked with a USTRUCT(), so maybe something about the entire process is just wrong?

---

<div class="post-metadata">

**Author:** ![Lardo\_Deepdelver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lardo\_Deepdelver](https://forums.unrealengine.com/u/Lardo_Deepdelver)\
**Post date:** [April 23, 2019, 2:33pm UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698/6 "2019-04-23T14:33:46Z")

</div>

K had a little look around apparently if you bind something with the AddUObject method it doesn’t have to be a UFUNCTION

go figure…  
so remove that and it should be fine.

example for that in the engine would be in AITask\_MoveTo.h

---

<div class="post-metadata">

**Author:** ![Good\_Laugh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Good\_Laugh](https://forums.unrealengine.com/u/Good_Laugh)\
**Post date:** [April 23, 2019, 2:41pm UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698/7 "2019-04-23T14:41:55Z")

</div>

This works!  
Thank you very much!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9ffccaa1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9ffccaa1](https://forums.unrealengine.com/u/anonymous_user_b9ffccaa1)\
**Post date:** [August 14, 2019, 12:00pm UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698/8 "2019-08-14T12:00:04Z")

</div>

This also worked for me, thank you!

---

<div class="post-metadata">

**Author:** ![zeez1911](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zeez1911/32/780501_2.png) [@zeez1911](https://forums.unrealengine.com/u/zeez1911)\
**Post date:** [January 5, 2024, 8:56am UTC](https://forums.unrealengine.com/t/binding-to-upathfollowingcomponent-onrequestfinished-event/447698/9 "2024-01-05T08:56:35Z")

</div>

Thank you.
