[Multiplayer] Change character speed if moving left/right/backwards

So yeah, how to change character speed on server depends on character movement direction?
I understand how to do that on client, but how should i do that on server?

I tried to create something “big” but still can’t make it work as it should.

I want my character sprint when pressed: W || W+D || W+A

My something “big”:

This called in Tick on client and server at each character on map.
SetMovementMode changes speed.
1 - DefaultSpeed.
2 - SprintSpeed.

Try using the scale value of the Add Movement Input, by default 1 is used however you can scale it down for less movement speed and it’s replicated by default.

When you press A or D check the direction if it’s around 90 or -90 then maybe use a 0.5 scale instead.

Everything you said can be controlled only on client side. :frowning:
I can’t find way to get Value from axis on server, movement replicated by different way.
I don’t have problem to check direction or change speed on client side. I can even notify server about my movement direction and everything will work. But if someone wants to cheat and say to server via RPC change my movement speed because i’m moving forward… While he moving backwards, he will move backwards with SprintSpeed.

It is something you do client side but it is already replicated through the character movement component, what you’re really changing is the scale value of the Add Movement Input function which you are already using to move around.

Yeah, i could change scale value on CLIENT.
What if client wants to cheat and change this value to something else?

I’m looking for server side solution. Players moves, server decides players speed.

The scale has a max value of 1 even if they change it to something higher it will not work, and server still has authority over movement.

How does your character move currently, do you have custom logic for movement or you still use the Add Movement Input function ?

Yeah, i use AddMovementInput.
Okay, if 1 is max value means SprintSpeed then cheater can send 1 while moving backwards, so he will sprint backwards. Even if i programmed to send 0.5

But that’s something you can easily detect if they’re teaching.
The issue with the mouse is the direction changes when the mouse is moved while D or A is pressed.
Maybe try a bigger range ? Also you don’t have to do it on all clients just the server and the local player.

if(HasAuthority() || IsLocallyControlled()) 
{
	const float Direction = GetDirectionYaw();

	if(UKismetMathLibrary::InRange_FloatFloat(Direction, -60.f, 60.f))
	{
		//Strafing
	}
}