How to update MaxWalkSpeed on Server from client on tick

Hey y’all so I’ve been stuck on trying to replicate character movement for an unholy amount of time. Currently I’m performing a set of calculations on each tick from my PlayerCharacter class to determine their max speed which is also updated on tick by accessing and setting it through the movement component. This works perfectly for standalone and listen servers. To not burden the server with this kind of computations during tick, I’ve tried creating an RPC call from the client to run in the server from this same ExecMovement speed function. Pretty much all this call does is it takes in the final computed speed and sets the MaxWalkSpeed of the PlayerCharacter’s movement component to that value. I thought that setting the same value in the client and server would keep the player movement synchronized. The issue is that this doesn’t seem to actually work and the MaxWalkSpeed can never be increased beyond the value that is initially set. I’m happy to provide code samples and I’ll really appreciate any and all feedback on how to tackle this issue, thanks!

I don’t change it on tick, just when a key is pressed and released, but it does work:

void MyCharacter::SetWalkSpeed()
{
	float NewSpeed;
	if (bIsRunPressed)
	{
		NewSpeed = RunWalkSpeed;
	}
	else
	{
		NewSpeed = NormalWalkSpeed;
	}
	
	CharMovementRef->MaxWalkSpeed = NewSpeed;
	Server_SetMaxWalkSpeed(CharMovementRef, NewSpeed);
}

void MyCharacter::Server_SetMaxWalkSpeed_Implementation(UCharacterMovementComponent* InMovementComponent, float NewSpeed) 
{
	if (InMovementComponent != nullptr)
	{
		InMovementComponent->MaxWalkSpeed = NewSpeed;
	}
}

Don’t know about doing that on tick, maybe a delay between the client and the server interferes somehow?

Thanks for the reply Tuerer! I initally was not passing a reference to my character’s movement component, so I thought that might have been the culprit. However after I fixed it the behavior continued. For reference, this is my part of my ccompute velocity function.`UVMovementComponent* MovCompRef = GetVMovementComponent();

	// If Sprinting on ground and input is facing relatively forward while doing so, increase speed gradually, no sideways or backwards sprinting
	if (bSprinting && !bWallRunning && GetVMovementComponent()->IsMovingOnGround() && FVector::DotProduct(GetVMovementComponent()->Velocity, GetActorForwardVector()) > 0.6f)
	{
	// While our current max speed is less than our sprinting speed raise the speed ceiling
		if (GetVMovementComponent()->MaxWalkSpeed < TopSprintSpeed)
		{
			// Can't go faster than top speed
			NewComputedSpeed = GetVMovementComponent()->GetMaxSpeed();
			NewComputedSpeed = FMath::Clamp(NewComputedSpeed += (TopSprintSpeed / RunningAccelerationStepSize * DeltaTime), BaseWalkSpeed, TopSprintSpeed);
			GetVMovementComponent()->MaxWalkSpeed = NewComputedSpeed;
			
			SetCurrentVelocity_Implementation(MovCompRef, NewComputedSpeed);
		}
		else if (GetVMovementComponent()->MaxWalkSpeed > TopSprintSpeed)
		{
			NewComputedSpeed = GetVMovementComponent()->GetMaxSpeed();
			NewComputedSpeed = FMath::Clamp(NewComputedSpeed -= (TopSprintSpeed / RunningDecelerationStepSize * DeltaTime), BaseWalkSpeed, TopSprintSpeed);
			GetVMovementComponent()->MaxWalkSpeed = NewComputedSpeed;
			SetCurrentVelocity_Implementation(MovCompRef, NewComputedSpeed);
		}


	}`

This is my function to change the velocity on the server:

void AVanguardFPSCharacter::SetCurrentVelocity_Implementation(UVMovementComponent* InMovementComponent, float Velocity)
{
	if (GetLocalRole() == ROLE_Authority)
	{
		if (InMovementComponent != nullptr)
		{
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("Wanted Speed is: %f"), Velocity));
			InMovementComponent->MaxWalkSpeed = Velocity;
		}
	}
}