Character Movement max walk speed replication?

Hello,

I’m working on a FPS project with blueprints and I face the following problem : only the player of the listening server can see his max walk speed changing.

Here’s the event on the character blueprint and the associated function :

7013-event.png

This is doing great on a listening server, but isn’t working on my clients. Why ?

I’ll answer my own question :slight_smile:
I solved the problem with function replication :

On the character :

The “Set Computed Max Walk Speed” function content :

It has to do with the way how listen servers work.

Only the server is allowed to do stuff. So if a client wants to change a replicated variable, he needs to tell the server to do so.

So what Fitiwizz does is, make a custom event that runs on the server but is called by the client. If the client presses the InputKey for sprinting, the event is called and passes the isSprinting bool. For pressed → true and for released → false.

Now, under the Input, you see the red part of the custom event. This runs on the server and sets the replicated variable “isSprinting” to true or false.

Nearly the same happens at the right side of his picture. He calls the custom event that runs on the server to change the movement speed of the Character Component that was passed at calling (so the one of the client).

For this RPC like network system, you need to realize, that every other player than yourself, is only a “bot” moving with the variables that the original one replicates. And the server is able to change variables of all these client bots and also change these variable on every one of your client bots.

So if Client1 Sprints, the server tells Client2 etc that Client1 Sprints. It also allows Client1 to sprint, because it changes the variable for him.

So on the server, you could also run some checks, to make sure that the player is allowed to sprint at all (cheating). But i guess it’s fine how he did it (:

Hey Fitwizz - I am running into the same issue here, however I lack the brains to understand what you have constructed here. Would you be able to post what steps you took to build the blueprints you posted?

Thanks for the prompt reply there eXi.

That clears up the understanding part very well indeed so a big thanks for that.

The issue of reproducing it still is there though. I’m not sure what Events/Functions/Settings I’m meant to be creating.

Sorry for my basic knowledge!

hmn I’ve the same approach as you did and it isn’t working for me using Set Max Fly Speed…max fly speed is only changing in server.

Yeah same issue here, cant change max fly speed on a client.

That Event tick looks so bad and it’s not really needed.
The trick is setting the max speed on the client and on the server (the last one through RPC call aka Custom event on server)

You’re setting the speed locally and the server is correcting. This is why you jitter.

You need to have the server change your characters speed as well.

Set speed locally, then RPC to server to change speed.

iam confused, when i try to change the max walk speed the speed doesn’t change and the character keeps glitching, i’ve been trying to fix this for a week now

This is what I did and it fixed mine :))
Multicast doesn’t work, maybe there’s an order for the server to do things.

2 Likes

This is the correct way. You can even do it client, then server. The server will replicate your speed to other players.

Here’s how I do movement speed changes (simplified).

https://i.imgur.com/kAToIR1.jpg

You can extend this event to handle all movement speed changes. max swim, crouched, flying etc. One event to handle all speed changes.

1 Like