Download

Network Friendly ClickToMove with Possessed Pawn?

I need a click to move function that works with multiplayer and possessed characters.

The method used in TopDown template works fine in single player, but as noted in several posts and answerhubs, SimpleMoveToLocation was not designed for multiplayer. Apparently neither was MoveToLocation. I pulled all pertinant MoveToLocation from the AAIController and added it to APlayerController and I get the exact same results. What you see on the client is an incredibly slow rotation and unsuccessful attempts to move.

Oddly enough when you tab off of the client everything works fine. This strange behavior is reproducible in the base TopDown template as well. But clicking to move and then having to tab off is not acceptable.

I have spent a lot of time looking at code in CharacterMovementComponent and PathFollowingComponent but I’m afraid its mosly beyond my kin.

So how would we go about implementing a real usable ClickToMove function that is network friendly and works with possessed pawns?
Using a proxy pawn is not a solution in my case.

Many Thanks
Jake

Can’t remember off the top of my head, but the first problem is likely that the Pawn already exists in the world when you press play (I think it is anyway). In order to a Client to properly possess and send commands to the Server, the Pawn first needs to be spawned on the Server (and thus will automagically replicate down to clients).

At that point, you should easily be able to send an RPC to the server via the Pawn or the Player Controller, which only sends the desired target world location - and the server will then execute the MoveToLocation / SimpleMoveToLocation logic. It’s not that they’re not “network-ready” as such, more that they don’t do anything network specific. You need to make sure that the Server is running the AI commands, and then you can rely on Replicated Movement to ensure your local copy of the Pawn is in the same place.

Hello TheJamsh,

I appreciate the reply, but your last sentence there is basically the nut of my issue. I’m not using AI commands. I’m possessing the pawn directly (not a proxy pawn setup). It’s easy enough to implement a server side RPC that calls MoveToLocation, or SimpleMoveTo, however when this RPC is called from a client it will only affect AIControlled pawns. It has no effect on PlayerControlled pawns. That is why most people use the RTS style proxy pawns and then bridge the calls to an AIControlled pawn on server.

I don’t want to do that. I mean, I can do that and actually I am currently doing that. But I don’t want to. Among other reasons, I see that this movement seems to have a lot of overshoot and pull back corrections.

I want to be able to use pathfinding on a possessed network client.

Thanks