It seems jumping isn’t replicated. It’s probably because jumping can be implemented in various ways. Ie. You can have instantaneous jumps, or sustained jumps (you jump higher the longer the button is held down), or double jumps. It also uses physics.
Crouching is a bit simpler in comparison to that, and it’s a constant state.
It may be a valid explanation. But I don’t understand it.
Crouch has a boolean to specify whether you want it to replicate its state.
bool bClientSimulation = false;
So you can (and you must) specify when the jump starts and ends… regardless of how complex it is and what are you doing in between.
Character->Jump(); // -->Start: (bool IsJumping=true)
// in the meadle of the jump do whatever you want
Character->StopJumping(); // -->End: (bool IsJumping=false)
I really wanted to use the engine provided property for the jump and thus not replicate two variables for the same thing (as with crouching).
But hey… it’s not the end of the world either. I will use my own replicated variable.
Jumping is replicated, it’s part of a bit flag system that the character movement component uses, the component has some flags like bWantsToCrouch and bWantsToJump, these flags are set by the client when you press a button to jump for example, gets simulate client side and those flags are sent to the server and the server does the same simulation and network prediction/replication.
I recommend watching a video about extending the character movement component for adding other modes and flags it’s the same concept applied to crouch and jump.
You don’t necessarily need to call StopJumping() in the game, and in my code I don’t call it. ResetJumpState() is already called when the movement mode is changed, which occurs when the character lands and the player isn’t pressing the jump button.
Looking into it a bit further, Kaidoom mentioned bWantsToJump, which doesn’t exist, but I think they meant bPressedJump which seems to be replicated. See UpdateFromCompressedFlags() and ClientUpdatePositionAfterServerUpdate().
On a side note, the movement class is 13395 lines of code, which is disgusting, and makes it hard to follow the logic. Epic should really refactor that junk.