Character Jumping: Replicate to other Clients

I’ve got a simple question.

How can I make a Character::Jump() call properly replicate on all clients in a network game?

I have some code in an overriden OnJumped() function and I need it to execute in order to change states in my animation blueprint.

From the client who pressed the jump-button I call a server function that calls Jump() on his character.

In the OnJumped() event, I display an onscreen-message, which is how I know that it only gets called on the initial client and the server but not any other clients. And so the jumping animation only gets played on that client.

Your doing it wrong - and if this is third or first person templates it should work out of the box.

But if your doing a clean slate and need this functionality here it goes:

From wherever your handling your input action mapping (Character or Controller BP) do the following:

1: Create Event node for your Input Action Mapping (Jump)
2: on PRESSED → Switch Has Auth → (remote) Jump (BP Node) → ServerStartJumping(Custom Event)
3: on RELEASE → Switch Has Auth → (remote) Stop Jumping(BP Node) → Server Stop Jumping(Custom Event)
4: From your custom event functions - setvar IsJumping=TRUE (Boolean) & setVar IsJumping=False (Boolean) respectively

IN ANIMBP
1: Cast to PlayerController or CharacterBP
2: Before any code - get these variables (REPLICATED) from said Blueprint & Set vars in AnimBP (NOT REPLICATED)
3: Handle your state/animation/slot for doing whatever animation is your said Jumping (this workflow is for ALL animation replicated in networking model).

Here’s where i found this information - i too was havin the same issues with Aim Offsetts & other various states… once you understand this method of Replication (and Ownership is the real culprit here) you’ll be flying high again!

Cheers!

Should be the same workflow/practice… just C++ instead of BP’s. Conversion is the point where you’ll be having to figure out… i’m not at the point of doing C++ yet sorry.

Thanks for your answer.

I’m gonna try to do like you describe step by step now, but I want to use as much code (vs. blueprinting) as possible. I hope I will be able to adopt this somehow.

No problem :slight_smile:

Quick question: when you write “(remote)”, does it mean a NetMulticast-function?

if REMOTE is the same as the blueprint node - this means the code recognizes the current logged in user as CLIENT - and continues to run that code you have after such as CLIENT

Ok, I’ve got it now.

Crouching seems to work fine, if I simply call Crouch() and UnCrouch() on the server. For jumping it was a little more complicated. I have to do a Multicast that checks CanJump() and then triggers the animation. First I tried to do this with overriding OnJumped_Implementation, but that function seems to only ever get called on server and owning client, even when you call Jump() on not-owning clients.

I don’t get it though… When you look at the function declaration/definition of OnJumped(), there is no reason why it shouldn’t execute on all clients, at least none that I could see.