Problem with jump and multiplayer

Hi,

So I started from the third person template and the jumping is working correctly in multiplayer without doing anything, but I would like to execute the jump only on the server (Tell me if I should not do that, but from what I understand everything should be done on the server)

So I did this :



void AMyProjectCharacter::OnStartJump()
 {
     if(Role < ROLE_Authority)
     {
         ServerOnStartJump();
     }
     else
     {
         Jump();
     }
 }
 
 void AMyProjectCharacter::OnStopJump()
 {
     if(Role < ROLE_Authority)
     {
         ServerOnStopJump();
     }
     else
     {
         StopJumping();
     }
 }
 
 void AMyProjectCharacter::ServerOnStartJump_Implementation()
 {
     OnStartJump();
 }
 
 bool AMyProjectCharacter::ServerOnStartJump_Validate()
 {
     return true;
 }
 
 void AMyProjectCharacter::ServerOnStopJump_Implementation()
 {
     OnStopJump();
 }
 
 bool AMyProjectCharacter::ServerOnStopJump_Validate()
 {
     return true;
 }

The result is that now the Jump is working correctly on the server but on the client I can’t jump anymore any ideas why ?

Try this:


void AMyProjectCharacter::OnStartJump()
 {
     if(Role < ROLE_Authority)
     {
         ServerOnStartJump();
     }


         Jump();

 }
 
 void AMyProjectCharacter::OnStopJump()
 {
     if(Role < ROLE_Authority)
     {
         ServerOnStopJump();
     }


         StopJumping();

 }

In your current logic, if you are not the server, you ask the server to call Jump, and in your local machine this would not happen, because of the else scope. The catch here is that you should sync the call both in server and in your local machine.