why is the jump not replicated by default? Or is it?

I’ve been looking for something like this but for the jump:

I tried this but It is “false” during the entire time the character is in the air
10

Why is the jump not replicated by default? Or is it?
If so. What is the replicated variable for the jump?

Thank you so much!!

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.

1 Like

Hi @xenofsnstudios

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.

Thank you very much for your reply :heart:

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.

1 Like

bWantsToJump doesn’t exist… at least in UE5.5.1 version

I will look for those videos!!
Thank you very much for your response!!

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.

Yes, (bPressedJump = true) and (Character->Jump()) do the same things…
They activate a physical impulse in the capsule (the jump itself).

But they say I should use Jump() function instead

Unfortunately it is not replicated… it’s a shame… I would like to expose this variable in the AnimBlueprint

I agree…
I was expecting the Jump() function to be in the character movement class…
However, it is in the character class. It’s a little confusing.

Thanks for your reply!!

Yeah bPressedJump is what I meant, it is replicated if you call the jump function bPressedJump will be true in both client and server.

It’s already exposed to BP with that blueprint ReadOnly and can be accessed in C++. It’s part of the character class.
image

For your anim BP you can use IsFalling which should be true when the character is jumping
GetCharacterMovement()->IsFalling()

I heard they’re working on improving the character movement component making it easier to add new modes, finger crossed.

2 Likes

So… They duplicate the same variable in the ACharacter class and in the UCharacterMovementComponent class too. (that’s curling the curl).

I expected a replicated variable to have the “replicated” modifier in the UPROPERTY macro…
UPROPERTY(Replicated)

They must be replicating it in another way then.

I’ll try it anyway… I’ll also try IsFalling()

If it works to replicate the jump animation then that’s what I’m looking for.

I hope you’re right.

Thank you very much for the help @KaidoomDev

1 Like