Adding UPathFollowingComponent to a PlayerController

When I add the

UPathFollowingComponent* PathFollowingComponent;

To a custom player controller class, I get this error

2>  C:/Work/Projects/ProjectDivine/Source/ProjectDivine/Player/Controller/PlayerController1_Movement.h(19) : Unrecognized type 'UPathFollowingComponent' - type must be a UCLASS, USTRUCT or UENUM

Anyway to fix it?

I want to use PlayerController but copy the other parts of the PathFollowing component to it.

You’d need to include PathFollowingComponent.h, or add class UPathFollowingComponent; somewhere at the top of the file.

Cheers,

–mieszko

Well I have those.
I removed temporary files and regenerated the project files and got a new error this time.

It looks like there are some dependencies missing or something

2>     Creating library C:\Work\Projects\ProjectDivine\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-ProjectDivine.lib and object C:\Work\Projects\ProjectDivine\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-ProjectDivine.exp
2>ProjectDivine.generated.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UPathFollowingComponent_NoRegister(void)" (__imp_?Z_Construct_UClass_UPathFollowingComponent_NoRegister@@YAPEAVUClass@@XZ) referenced in function "class UClass * __cdecl Z_Construct_UClass_APlayerController1_Movement(void)" (?Z_Construct_UClass_APlayerController1_Movement@@YAPEAVUClass@@XZ)
2>C:\Work\Projects\ProjectDivine\Binaries\Win64\UE4Editor-ProjectDivine.dll : fatal error LNK1120: 1 unresolved externals
2>ERROR : UBT error : Failed to produce item: C:\Work\Projects\ProjectDivine\Binaries\Win64\UE4Editor-ProjectDivine.dll

Hey envenger!

Could it be that you forgot to add AIModule to the Dependencies?

To do this go to the MyProject.Build.cs file and add “AIModule” to the PublicDependencyModuleNames.

Hope this helps :slight_smile:
Elias