So I’m trying to create a game where right-clicking makes your pawn move to the target point through pathfinding. However, SimpleMoveToLocation isn’t supposed to be use in a network environment (source: Does UE4 have client-side prediction built in? - UE4 AnswerHub) and MoveToLocation is only available in AIController.
To solve this problem, I implemented Droneah’s solution found here: http://droneah.com/content/ue4-getting-multiplayer-player-pawn-ai-navigation-work-c which basically has two pawns and two controllers (a custom PlayerController and a default AIController) and then tries to sync the pawns properly. This worked okay I guess, but it’s just becoming very clunky to work with.
I decided to try and refactor the code into something less obnoxious to work with and searched around a bit. I found this: Accurate Alternative for 'Simple Move to Location' - Blueprint Visual Scripting - Unreal Engine Forums which seems to suggest that I can cast my PlayerController to an AIController and then use MoveToLocation. I was a bit dubious and as I thought, the cast ends up returning NULL.
It seemed a bit annoying to me that there’s no direct access to pathfinding in the Playercontroller since a lot of games need it (MOBAs, RTSs, etc). But I didn’t give up, so I tried making a wrapper that inherited PlayerController and then copy all the pathfinding logic from AIController over to it. Despite it breaking the DRY principle, it sounded like a good idea at the time. However, I got stuck on a compilation error on “DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FAIMoveCompletedSignature, FAIRequestID, RequestID, EPathFollowingResult::Type, Result);”. Some problem with FAIMoveCompletedSignature.
However, I didn’t give up! I kept searching and found a reply by MieszkoZ saying that the correct way to do this is with a PlayerController without a pawn controlling an AIController with a pawn. This still seems kind of messy to me, but at least I can remove the proxy pawn that I’m currently using. Is that the right way to go about it?