Server OnLanded to client

I have two players: Server and Client. I want to know from the client side if server has landed or not. So I used Event OnLanded and replicated variable but this method doesn’t work for me. Is there a way to have client know when server has done Event OnLanded?

Try this:

I’ve already tried it and it looked like this:


So theoretically when I jumped and landed on server, then switched to client and pressed X I should have seen “Client1: true” but instead there was “false”.

A. Did you do a “break” at the server’s “On Landed” event in the Editor to confirm it’s actually getting called.

B. Why not Just have the “Landed” variable set to Replicate with Notify? Then, on the client, have the “OnRepl_Landed” event do the Print String.

That may work out a bit better for you, but both approaches will be moot if the “On Landed” event isn’t even happening.

Method with RepNotify works for Printing String but I want to make something more complex. This is my double jump (and a part of dash).

And what I want to do is to make server jump whenever server or client presses space. I tried to have custom event been called from RepNotify, but it does not work. For now it looks like that: server can double jump and “Used Dash” is being set to 0, and on the client side: You can jump twice (or single double jump), but “Do N” does not reset nor “Used Dash”.

okay… what you just described differs greatly from the original question. I understand that you don’t want to share/show/give away any more IP than absolutely necessary, but you’re talking about Landed, Dash, and now Double Jumps.

Give us a hand and go through the concept from A-Z of what you’re trying to accomplish, and exactly what part is hindering your progress. Because this started out with just clients being aware of when the (or a) character lands on the server side.

Also… What exactly is the role of the Server? Is this a Dedicated server, or a user hosted game session?
There are big differences between the two, and how you go about implementing your logic. For example, it matters greatly in deciding what information should ONLY be handled Server side, and what information is okay to be handled client side.

I’m very sorry for the confussion.

The thing that I want to accomplish is to make server’s charcter jump whenever server or client presses space. The problem is that client himself is stuck to the ground so he cannot jump and then land. And if he is not landing “Do N” does not get reset and with that “Used Dash” (which is for another event, it just have to be reseted here).

So, summaring, client has to know when server’s character has landed because client’s character never lands. When landing happens “Do N” and “Used Dash” need to be reseted.

“whenever server or client presses space”

This is what confuses me the most… On a Dedicated server, no one would ever press “space” because no one is playing on the Server.

The scenario would be different if you’re talking about a multiplayer in which one of the players would be hosting their own game session. In this situation, the Hosting player is the server player.

How you would handle Server/Client Logic is a bit different depending on which scenario you’re using.

But one (of many options) would be to have your “Do N” and “Used Dash” variables to be Replicated.
Switch your “Landed” variable from “RepNotify” to “Replicated” as well. Unless you need the clients to do something on their side when these variables change

When the server event “On Landed” fires, you set the 3 variables as you see fit. Which will replicate their values down to the client.

This now brings you to another problem… Because Replicated variables can only be SET by the SERVER. So how do you do that?
Simple… You make a Custom Event in whatever Blueprint you’re working in. Set the replication property for that event to be “Run On Server”.
Make inputs for the values you need and Set the variables according to the input recieved.

Now, whenever something on the client side needs to set those variables, it calls the appropriate Server event you created above, and passes the desired value.

But I’m still unclear about the Server/Client Relationship you’re referring too… In my mind, we’re talking about one player, who has the client player they’re working with, and a Server version of their player which is on a dedicated server.

If you’re doing a Player Hosted Session, then what you’re calling Server/Client players are actually two totally different characters, and you’re needing to replicate what each other is doing; which would be a completely different solution than what I proposed above.

So you’re looking for the possibility of two different players being able to control the same character on screen?

Again sorry.

I was thinking about Player Hosted Session (not Dedicated), where the Host’s character’s jump can be controlled by Host himself or another Player that joined the session.

Yes, but not on the same computer, I’m using Steam Online Subsystem.

I use the “switch has authority” to test before playing my landed effects

You do not need to replicate this message to your client as it executes on both client and server by default

Is your game client/server? because you will still want it to happen for the authority if it is NOT a dedicated server as well

One of the players is hosting the server and others are joining it. All the clients have to know when server’s character lands.

the switch has authority also has a ‘remote’ path - that path will execute on your clients

i guess you could also isolate the is authority and have it blast out a multicast with guaranteed delivery as well - which is what I think you are currently doing - this stuff is really hard to isolate especially when you want it to work single, dedicated and peer host - i recommend using print strings, it thankfully tags if it is executing on client/server

Alternatively, create a custom CharacterMovementComponent and override SetPostLandedPhysics:

void UShooterCharacterMovement::SetPostLandedPhysics(const FHitResult& Hit)
	// call for non-authority only because this is already called for authority elsewhere
	if (CharacterOwner && CharacterOwner->GetLocalRole() != ROLE_Authority && CharacterOwner->ShouldNotifyLanded(Hit))