Stamina - Mulitplaer

Hello,
Iv’e been trying to create a stamina bar ( with no dedicated server and 1 player).
and the stamina doesn’t working when running… and the editor giving me the following errors:

and here is the character BP:

here is the widget BP:

and [here][6] is a video about what happening when using dedicated server and not using dedicated server:

thanks for help.

Thank you so much! the stamina is changing now but the running problem is still existing. same as in the video first part ( not running and flickering screen ).

sorry but i don’t completely understanding you ( multiplayer is kind of new to me ). by modify you mean ‘Set Max Walk Speed’ ? or Events Replications ?

Thank you so much!
btw, i created the custom event with server rpc like you said and i added to it Input which is float and put the event with ‘Set Max Walk Speed’ on pressed and released and change the float number by the number your character is moving. ( for people that might get it helpful ). and again thank you :slight_smile:

Hey!

Some networking teach here :wink:

No matter if you using dedicated server or just play with two player without dedicated server (in this case we talkig hosted/listen server) in every solution always will be one authorative server.

In dedicated mode is the server itself
In listen server mode is the first client.

Two main problem you did.

First:
Dedicated servers will not have any render data, so when you play in dedicated server mode you need to create your widget only on client (has authority node).

Second:
You creating widget in BEGIN PLAY! begin play will be executed in every client and server.

What that means?

If you play with two player (no matter if dedicated or not, multiplayer :wink: ), two begin event will be called on server because there is two live character are present.

On Client 1 again two begin play will be executed, because one for owned pawn and one for simulated character (other player)
On Client 2 again two begin play will.be executed, because owned and simulated pawn :wink:

Basically pawns are exist in every client and after spawn engine will call begin play event, but because simulated pawns (other players) do not have player controller (because only local player have their player controller) engine cant create widget and add to viewport :slight_smile:

You can simply fix this with IsLocalPlayer node after you fixed server bug what i told you before…

So concept is this. Put HasAuthority node after begin play, on remote branch check IsLocalPlayer and if true add widget :wink:

Yeah, you need modify walking speed on client and on Server too.
Currentky you modify only on client when sprint presses :wink:
This will modify the max speed on client and client try run faster but on server you have old max speed, so server will restrict that speed to old value.
This is why you see flickering :wink:

On your first picture:

InputActionSprint if stamina > 0 → set max walk speed 475 ← this is bad because this will run only on client.

Create a custom event like your Run On Server, just name it as Set Max Speed on Server (of course this need to be server rpc)

After set max walk speed happens when key is pressed and max walk speed are set call this event to set max walk speed on server too