Issues with AIController based Topdown character and replication

Hey, I’ve been banging my head against this problem for days and figured its finally time to ask for some help. I’m new when it comes to Multiplayer and replication so bear with me.

I’m making a Topdown based multiplayer game with point and click movement controls, but in order to achieve stutter-free character movement I followed this tutorial on improving the movement synchronization between client and server.

Basically from what I understand the characters are possessed by a server based AIController and go where the client based click to move location is indicated. (see vid for blueprints, full overview at the end of the vid)

However here comes the issue (and I havent 100% figured out whats going on yet so I could be wrong) - Because these characters are owned by the server controller I cant seem to access the Run on Server RPC from the client controllers. So if I want to ie. play a montage from a client I am unable to replicate it to other clients or server. The server window replicates it just fine.

Blueprints:

ClientController Blueprint casting to Character Blueprint triggering the animation.

Character Blueprint

Video of the issue

Hoping a more experienced multiplayer dev has ran into similar issues…

Also I’m not married to the AIController based movement so if anyone has better click to move solutions let me know.

That’s what you would do for “detached” characters, yes. If you have a single player character, that goes where you click, you would instead use a PlayerController for the character, both on server and owning client. MoveTo behavior based on navmesh is a feature of Character, not only a feature of AIController.

If you need more than one character (squad or RTS style) then you’ll still want to run a player controller on the server, and use Run On Server to send RPC to the player controller with the desired target position, and then have the PlayerController on the server find the appropriate AI characters and tell them what to do.

In general, “play montage” should be done in response to some particular stimuli on the character – it should not be DIRECTLY forced by a player. Thus, it’s up to the PlayerController running on the server, or just basic environmental factors, to arrange for the right stimuli to appear.

Interesting, thanks for the reply.

I need to have low ground friction and brake deceleration on the characters to make them feel sluggish when moving. With the topdown template MoveTo started stuttering when replicated so I went with the detached character approach which worked without stuttering right away.

In general, “play montage” should be done in response to some particular stimuli on the character – it should not be DIRECTLY forced by a player. Thus, it’s up to the PlayerController running on the server, or just basic environmental factors, to arrange for the right stimuli to appear.

Ok so if the rts squad style characters need to stop to attack and play ie a shoot animation, how would I apply the right stimuli to play that animation? Or is it better to use the state machine in the Animation blueprint? Wouldn’t I still need to manipulate the transition conditions in that case?

Yes, typically what happens is the character has some “state” which is updated by AI or physics or whatever. Jumping, Shooting, Running, …
Then the animation blueprint actually arranges for playing the right animation.
Sometimes, specific interrupts (“pick up this thing on the ground”) have specific high-priority montages that override the blueprint, but those still generally come from whatever event it is that decides to put the character in that state, rather than directly saying “play pick up animation.” Sometimes it’s kind-of subtle, because it’s not black and white :slight_smile:

Anyway, sounds like you got the “forward the commands to the server playercontroller using RPC” working? Problem solved!

Yeah here is the solution

thanks to everyone who helped :slight_smile: