#multiplayer

1 messages · Page 56 of 1

real ridge
#

it gets deleted then

#

so I am getting name from game instance

winged badger
#

service will initialize the playerstate's name

#

as well as their unique net id

real ridge
#

first I have login which happens out of server my name will store players name who logged for example Laos, BlackHawkSK and then I am getting those nicknames from gameinstance

#

i cant store it in playerstate

#

because after joining game/session

#

its get deleted

winged badger
#

your gamemode has the login string

#

it also has RenamePlayer or something very similar function

real ridge
#

i have this login screen

winged badger
#

which will set the name on the PlayerState

#

for that player

real ridge
winged badger
#

and then you let the engine do the rest for you

#

it doesn't matter

real ridge
#

anyways if I tried this with player state instead of variable ina playerpawn it will work?

winged badger
#

if its hard travel (connecting to a different server) you can provide the name via login options

real ridge
winged badger
#

if its inter-server travel, PS will copy the name to the new instance

real ridge
#

idk how to explain

winged badger
#

also, as Jambax mentioned, replicating FText is bad, FText is there to handle localizations

real ridge
#

i will log in i join lobby its created with my own database and websockets then I make search for game and when they hit play they are joining to session on dedicated server

real ridge
#

what I did

winged badger
#

all UMG bindings are terrible

#

but if you have to replicate text, replicate a string

real ridge
#

anyways , question is

#

what then? cast to player pawn in widget and get variable there?

#

i am lost now XD

#

I dont want go through player state

#

as I know its deleted

winged badger
#

playerstate will survuve anything pawn will

real ridge
winged badger
#

or controller

real ridge
#

btw where u from why u have nick zlo

winged badger
#

croatia

real ridge
#

cool i thought u from slovakia its like our word

#

i saw u have snow now in croatia

#

heh

winged badger
#

basically

#

joining a session is not the same as joining a server

#

2 usually happen at around the same time

#

but are not the same

real ridge
#

i am trying now solve replication XD just simple get it from my pawn to all

#

ahhh

winged badger
#

when you are joining a server, you can push extra data (like your nickname) via login url

#

which gamemode parses in its prelogin/login

#

at this point, GM has created a controller and a playerstate for you

#

and you can Rename yourself, setting the name on the PS

#

and that happens every time you join the server

#

for changing maps within the server, PS does get destroyed, but not before it copies properties to the new instance of the PS

#

therefore, persisting your nickname

winged badger
#

that is called seamless travel

real ridge
#

i will note it

#

so bind is not the way yes? for my names now

#

ok so I did it via RPC

kindred widget
#

I still love writing that name, it never gets less ridiculous.

real ridge
#

guys when I now see each other names why when someone join later I dont see name of players already connected?

#

like they are not refreshed

kindred widget
#

Cause you're setting it from a mutlicast.

real ridge
#

lets say player 1 join his name is Emanuel player 2 join his name is Robert, Emanuel can see Robert name and his also but Robert doesnt see Emanuel name only own

real ridge
kindred widget
#

And Multicasts don't hold state. They broadcast once at the time of calling. Emanuel broadcasts his name before Robert joins in. Emanuel never told Robert his name after Robert joined.

#

Which is you you should use the PlayerName in the PlayerState mentioned above, which is already replicated for you and in the correct PlayerState class.

real ridge
#

hm

#

so anyways I need store variable in player state

#

should I create variable name in player state and set it replicated?

kindred widget
#

PlayerName already exists in the playerstate. It's a native variable.

#

@real ridge

real ridge
#

as I know

#

I have nicks i cant use default code from pc

#

as player name

kindred widget
real ridge
#

hm so like this?

#

dont i need some function which will always load all names of players in game?

torpid nymph
#

anyone has some pointers on getting replicated vehicles going? few years ago I tried to do something similar and there wasn't really a lot of out of the box support for it, has it changed with chaos?

real ridge
#

unfortunately

#

did you solve this ? I have similar problem now when I join with another player he does not see names of already connected but they see his name

vapid sleet
#

Hi guys,
Im on UE 4.27 C++, Using a Multiplayer System, I create a session with the Online::GetSessionInterface etc. Bound to the OnCreateSessionCompleteDelegate I do UGameplayStatics::OpenLevel(...) so the host loads the Level.
Now I started experiecing getting the Error Faild to load ´/Game/Maps/UEDPIE_0_SampleLevel´: Can´t find file.

I already found this post explaining how to fix it but it happens every time again after one fix
||https://forums.unrealengine.com/t/failed-to-load-map-warning/622043/7||

Any idea whats causing it?

quasi tide
sonic python
#

Heyy

#

in mobiles

#

Is this enough to implement lan? like will player be able to play?

limber gyro
#

guys i cant create a session, quit, and then create another. I assume its because the other one is still running, how do we handle that node wise? is there anything to handle that, or do i have to like store the previous session and then kill it when making a new one?

kindred widget
limber gyro
#

im using steam

kindred widget
#

The AdvancedSteamSessions plugin or whatever it is?

limber gyro
#

ye

kindred widget
#

Hmm. I don't know if it has anything specific, I've never personally used it. But normally you should just be able to call DestroySession.

Having said that, if you have the time I would recommend checking out the CommonUser plugin and using CommonSessionSubsystem. It basically generically wraps the OSS stuff for all platforms really nicely.

limber gyro
#

i would also like to know best practices, is the player suposed to destroy the session when he leaves or when he creates another?

kindred widget
#

Probably when leaving. Traditional practice is usually to just make your main menu destroy sessions if I'm not mistaken. You're usually booted there for errors, or quit back to it when planning to host a new game.

limber gyro
#

that CommonSessionSubsystem plugin is for 5.0 im still on .26 unfortunately

quasi tide
kindred widget
#

Oof. Fair enough. We backported it for 4.27, but Kaos did a ton of work on it.

limber gyro
#

i will keep it in mind for my next game

quasi tide
#

Ah - a Lyra thing

kindred widget
limber gyro
#

example project i mean

quasi tide
#

I've been using AdvancedSessions all these years. Been workin' well enough for me 😅

kindred widget
#

Stuff like this.

quasi tide
#

🤔 - feel like this could've been a GI subsystem most likely.

kindred widget
#

CommonSessionSubsystem is a GameInstanceSubystem.

quasi tide
#

I'm talkin' about UCommonGameInstance specifically

limber gyro
#

is there any node to check if there is an active session?

kindred widget
limber gyro
kindred widget
#

There's an easy generic call for it. But you'd need a little C++ to make it.

#

Oh, wait, that's asking for a session name.

#

GetNumSessions might work though.

limber gyro
#

how do i track down which array is causing issues

#

i can check in the log that the game mode class is being initialized

#

my "login" function gets called

#

but then it crashes

#

on the array class

#

but i cant find the info on which array is causing the issue

kindred widget
#

Would need a callstack.

latent heart
#

Walk up teh call stack

limber gyro
#

never done that

#

do u just look at it like the log?

kindred widget
#

When you crash, you should be getting one.

#

If not, you need to install symbols.

limber gyro
#

i have it

#

im just not familiar with it

#

so i think its because of a FString

#

it calls postlogin

#

then an fstring

#

i think its an internal array

#

im assuming its crashing because its trying to make an array with nothing

#

request url should be empty right?

#

the call stack doenst show exactly what is being called?

#

ok do FStrings need to be initialized?

thin stratus
#

If you want help then you need to at least post us the crash error and the callstack that should be in the log

#

Otherwise this is just a guessing game

limber gyro
#

ur right my bad, i was just digressing i guess

#

well the error is an acess violation on an array

#

i suspect it might be because of an unitilized FString

thin stratus
#

This is quite hard to tell cause this log is missing symbols

#

That's why it's all UnknownFunction

limber gyro
#

oh i didnt know that

#

i thought i had all the proper stuff

thin stratus
#

Is this a packaged dedicated server?

limber gyro
#

where do i go to install the missing stuff? repair VS?

#

this was on a packaged client

#

i was trying to host a session

#

the call stack i posted up there

thin stratus
#

So a ListenServer?

limber gyro
#

ye

thin stratus
#

Can you reproduce this crash?

limber gyro
#

yes

thin stratus
#

Then attach VS to it

#

And make it crash

limber gyro
#

ive done the crash while running the solution in debuggame

#

its the same isnt it?

thin stratus
#

It is, didn't know you can cause the crash in non-packaged

#

Can you make a screenshot of (or copy/paste) the callstack you have in VS?

limber gyro
#

its up there but i can take another one

#

let me just check if its because of the FString

thin stratus
#

Callstack is usually a lot longer

limber gyro
#

well i cut of the irrelevant parts, i know where the crash is coming from

thin stratus
#

I can tell you that it would probably crash cause of the line above that

limber gyro
#

the last thing it calls in my code is that fstring

thin stratus
#

The NewPlayer->NetConnection stuff looks more sus

limber gyro
#

makes sense, if its not initialized it would be putting grabage inside that fstring

thin stratus
#

It might just crash on accessing any of those pointers

#

Why do you even need that there?

limber gyro
#

i was going on the assumption that, that line was clear because its pointing to the one below it

kindred widget
#

Sometimes the callstack does indicate the next line for some reason instead of the nullptr line.

thin stratus
#

Na, crashes and callstacks can be misleading

#

It can even point into functions even though it crashed while calling the function

#

(indicated by "this" being null in the variable view for example)

#

So you will always have to put some thought into it

#

Why do you need the RequestURL there?

#

If you need the Options of the Player you can use Login or PreLogin

#

And if you need the options of the Server you can just use the OptionsString

limber gyro
#

because i didnt know if if i could use a regular fstring between login and post login, i didnt know if the info changed because i didnt know if login and post login were async

thin stratus
#

They aren't async

#

Almost nothing is async in UE regarding the GameThread

limber gyro
#

well, you shouldve been here when i spent a whole afternoon looking into that xD

quasi tide
#

Yeah Cedric. How dare thee

limber gyro
#

by the time i figured it out i had that code done

#

so i just let it be

thin stratus
#

If you need the options in PostLogin, then you can simply process them in Login and save whatever yo uneed in the PlayerController

#

And then use that in PostLogin

limber gyro
#

makes more sense anyways

thin stratus
#

👍

#

But you can also first check if this is even the issue fwiw

#

By splitting the line into multiple ones

#

And by checking if valid

#

Like

#

actually checkf(condition, TEXT("Something went wrong."));

#

Will still crash but at least you know why

#

Also allows params

#

checkf(condition, TEXT("Something went wrong in %s"), *FString(__FUNCTION__));

limber gyro
#

i didnt even knew that function existed

thin stratus
#

Obviously "something went wrong" should be more descriptive

#

It's more or less c++ basics

limber gyro
#

unfortunately my c++ education in college was quite basic

#

and when u ship games from start to finish alone the c++ part has to fail somehow because u have to do everything

#

so ye, some times u gotta relearn the basics and all those neat tricks because the time you should've spent learning them u spent making some random jump sound or level design

quasi tide
#

It's when you venture outside of the C++ walls that Unreal has provided...that's when C++ gets top tier ridiculous.

thin stratus
#

Either way, test the pointers

#

If you need them to be valid, let it crash gracefully

#

I think I almost never have more than one pointer in a line

#

So I never do PointerA->PointerB->Function()

#

Almost never at least

kindred widget
#

Double ternarys are fun though. 😄

thin stratus
#

const FString WhatAmI = bIsADog ? (bIsABigDog ? FString("BigDoggo") : FString("SmallDoggo")) : FString("NoDoggo"); like this? :D

#

Pretty sure that would cry without ()

#

Sometimes I actually control flow with those

#

bSomeCondition ? FunctionA() : FunctionB();

#

Prettier for me than having a huge if / else for just a simple function call

oak oracle
#

hi devs , i am spawning a Shield Actor on the server , then i am attaching it to the character ,editing its offset and also some staff. This is all happening on Server (via Server RPC) . However all of this is also happening on client sides as well just fine .I accept that spawning on server will be repeated on clients as wlll but attachment and changing offset? how and why it is happening on clients also if i am only calling it on Server RPC ? here is a code for clarity

edgy patio
#

The attachment method has a RepNotify behind the scenes ^^

#

If you know a bit of C++ you can find more in the SceneComponent.h

abstract pike
#

Calling for anyone that has experience with Replication Graph: I'm seeing a weird behaviour where RPCs are causing replication even when the actor is not in the replication list.

I have a custom replication graph node which collects actors for the replication list based on vision. But for an actor that is out of vision (and is not in the replication list) if the actor calls a multicast it causes the actor to replicate still even though it's not in the replication list.

abstract pike
#

Hmmm actually it seems something strange is going on. Even when I don't add the actor to the vision node. It still replicates. So something else is allowing it to replicate but I've never seen anything that mentions a default node for replication graph...

rose egret
#

how do I know its Client build ? whats the macro for that ?

#

I know UE_SERVER means v r compiling for dedicatd server

crystal crag
#

Think for a moment

#

what's the opposite of that define

#

How do you negate it?

rose egret
#

its still 0 in standalone isn't it ?

#

I want to exclude my server codes from client version only, not listen server or standalone

crystal crag
#

If you wanted to include code only in a client build and you know that #if UE_SERVER will only include the code in the server... then there is an easy solution

#

without even having to look up other potential defines

#

one change can make that line work for you

rose egret
#

I guess there was another macro

edgy patio
#

You can check build configs inside Build.h

rose egret
#

WITH_SERVER or something like that

#

oh found it its WITH_SERVER_CODE

dark wyvern
#

I've got a lag / rubberbanding issue going on. This is happening in the editor when I test on a Listen Server with a Host and 1 Client. Theoretically there should be no lag when I'm testing on the same PC, right? Has anyone else experienced this? It's definitely possible I could have have changed a setting at some point to mess it up, but I have no idea. For the player there isn't much going on beyond the default FPS template. I only just noticed it when I replicated a basic elevator - the rubberbanding of the Client often causes the player to fall through the elevator.

verbal tendon
#

If your CPU utilization is maxing out, you will see rubberbanding

dark wyvern
#

Oh! hm.. I have a threadripper CPU. Maybe the editor isn't utilizing it properly? It should be plenty fast enough.

#

Thank you, that gives me something to go on

verbal tendon
#

Uhm. Yeah on a threadripper you should be fine

#

unless you are doing something wildly crazy

rose egret
#

what do you mean by lag ? low FPS ? use unlit mode if u have several PIE clients

dark edge
dark wyvern
#

I mean network latency. My FPS is fine, but I think @verbal tendon is on the right track. It seems something I'm doing is throttling the CPU. My "frame" value is off the charts if I bring up stat unit in the console. I'm looking in the profiler to try and figure out what it is.

dark wyvern
dark edge
#

What I'm getting at is that the elevator might not be in the same place on both machines. CMC does predictive movement, rubberbanding is corrections.
Try
NetShowCorrections 1

graceful flame
#

Say you have a character who respawns into a level and there's a multicast for a sound effect that plays so other players can hear them spawning in. How can I avoid that multicast for players who are beyond the sound's attenuation radius? I understand that currently with the multicast they still won't hear the sound if they're too far away which is the expected behaviour anyways, but I'm interested in reducing network traffic by avoiding the multicast in the first place. Is this something I would use Net Cull Distance for? I still want them to be seen when they respawn in though.
Is this just over optimizing something that isn't a big deal?

#

The answer to this question is important because it will become my standard way of handling multicasts for other things too.

quasi tide
#

You could just loop through the players when the server spawns the actor, check the distance to the spawned actor and then do a client RPC to all people within X range.

#

Net Cull will prevent you from seeing them as well.

graceful flame
#

Okay thanks, I think I'll try making a function or maybe a macro that does that. Sort of like a separate net cull distance that can be tuned for specific events and not just an all or nothing approach like the existing net cull distance.

worn steppe
#

How do I pass an ActorComponent to an RPC?

#

Or, possibly, just an actor to an RPC? I just need an efficient way to identify an actor I suppose, since I could grab the component in the RPC function

hollow eagle
#

the same way you pass them to any other function, assuming they are replicated

worn steppe
#

That seems like it would be too heavy

hollow eagle
#

Why do you think that?

#

You're not sending the entire object over the network in an RPC.

#

You're sending an id the engine assigns to networked objects.

worn steppe
#

I think the issue is that I don't really understand what the engine is doing then

hollow eagle
#

I just said what it's doing. It's sending an id that uniquely identifies the object.

#
UFUNCTION(NetMulticast)
void MulticastDoThing(AActor* SomeReplicatedActor);

is not sending the entirety of what you pass in to SomeReplicatedActor when you call it. It's sending an id in place of the actor, assuming that actor is replicated and clients have previously received it.

worn steppe
#

okay

#

I can follow that, but it begs another question, does this work for actors that are spawned at runtime?

#

I haven't done that yet but I plan to

hollow eagle
#

as long as they are marked as replicated, yes

worn steppe
#

awesome, thanks

near granite
#

In multiplayer, when to use the level blueprint?

quasi tide
#

Never

near granite
quasi tide
#

Yeah

near granite
#

wow.............suprising..that's why I have been in big trouble

near granite
# quasi tide Yeah

Do you know if the Level Sequencer blue print is also never used like level blue print in multi?

quasi tide
#

Level BP shouldn't be used at all. It is terrible for maintenance. To play a level sequence, just play it on all clients most likely. I don't mess with level sequences much.

quasi tide
#

Is there a way, in Rider, to debug the client code?

fathom aspen
#

Breakpoint an IsNetMode == NM_Client that succeeds 😛

quasi tide
#

That is garbage lol

near granite
#

In multiplayer, can more clients connect to a level than the player starts placed in level?

real ridge
#

guys how to load all names of joined players in game when I join? because when I play with friends I see their names also when someone new join I see his but he doesnt see other names because he is newly joined

#

like its not replicated for him

upbeat basin
upbeat basin
chrome bay
#

Also they may fail to spawn

#

So you need to handle that

upbeat basin
chrome bay
#

yee

#

By default the gamemode will just leave you in limbo if your pawn fails to spawn

#

So you need to handle that somehow yourself

real ridge
#

for all

#

in widget i have variable Name which is string

#

and I have text which have bind to this variable

#

its functioning all time just when new player join he doesnt see names of others

#

even its replicated

#

but anyway everytime player who join first as on the right image he sees all names of all players but player on the left screen see only his own and second plane has not changed name because he joined game after him

#

so its like not loaded for him

upbeat basin
#

If you want to fix this with the setup you have, every time a player joins the game, you would want to call SetNames for every player again

#

I would personally do this by creating a rep notify variable on PlayerState, call a server RPC at the BeginPlay to set it on server and update the variable in widget inside the RepNotify function

#

This way, any new player that joins later would be able to get every other player's name when their PlayerState is replicated to them, which would trigger the RepNotify function

#

There already is a replicated variable called PlayerName in PlayerState which I believe has a OnRep function as well, but you might need to do your own setup if you're on Blueprints

real ridge
#

hmm gonna check

#

so make rep notify in rep notify set variable in widget ?

#

or

upbeat basin
#

Yes to the first part, not sure about the or

#

Be aware that I suggested PlayerState because it's replicated to all clients and usually (or can I say never?) gets deleted

#

If you put your replicated variable in your Character class, destroy it when you're dead and spawn a new one, you'll lose the name and will need to set it again when you spawn the new character

#

Or if you chose PlayerController no other clients will be aware of that since it won't be replicated to them

real ridge
#

also is correct to have widget name here ?

#

sometimes its causing crashing of packaged game

#

idk why

#

I am getting blackscreen when I have bad widgets

real ridge
#

i am setting variable inside widget which I set also to replicated idk if its needed

#

but as I see now its not working for anyone

#

both should have name player

upbeat basin
#

Currently you're only setting it locally

#

That's why probably every player just sees their own name

real ridge
#

rpc like this?

#

bcs this not working

upbeat basin
#

Yes, Run On Server event

real ridge
#

it has same result

upbeat basin
#

Well, I might suggest you to look into the compendium and this diagram a bit more

#

But basically, let's say you there are 2 players and a server

#

Your PlayerState::BeginPlay will work on botn Server and on the clients, for each PlayerState

real ridge
#

i know bruh I had this done before now I am trying like 2 days with this easy thing and cant do it tried many ways..:D

real ridge
upbeat basin
#

Because you're calling your RPC on both server and client

#

Server's GameInstance will have no idea about what your client's GameInstance have as PlayerName

#

You should call the Server RPC only from the owning client

#

With an Auth check

#

You don't need the multicast RPC anymore since your variable is replicated

#

And Notify function should do it's magic to update the Widget's variable when it's appropriate to do

real ridge
#

should I add branch + is server?

#

or is locally controlled?

upbeat basin
#

IsLocallyControlled should be better

#

AuthCheck would probably not a good idea on PlayerState since it'll be false for every other client as well

real ridge
#

like this?

#

ah doesnt work

upbeat basin
#

You can plug your pawn to there

real ridge
#

but i need somehow cast to it first not?

#

omg... get player pawn...

#

unfortunately its same

upbeat basin
#

Well two things

upbeat basin
# real ridge like this?

You are not passing your playername in the RPC here, it's using it's local GameInstance's value and using a value from another execution line which might cause headaches in the future

near granite
upbeat basin
upbeat basin
real ridge
upbeat basin
upbeat basin
real ridge
#

so like this its still same I dont understand

worn steppe
#

are there any potential issues with replicating float values?

fathom aspen
fathom aspen
real ridge
#

wizard?

distant vault
#

Hello, for the steam online subsystem, do you have to have steam open to be able to host, find, join a session? When you packaged your game?

chrome bay
#

yes

twilit radish
#

Steam weekly maintenance about to ruin everyone's day 👀

real ridge
#

finally i found name how to replicate all names even I join later

#

this is working

#

its in widget and I am getting value from player state

#

which is replicated

distant vault
real ridge
#

Guys I need help/ tip I have "bomb" on map when I pick it It will get destroyed how I can say to all players it was taken? and start countdown?

#

pls 😄

hushed anvil
#

Hey there, does anyone know how can I retrieve the current session as a variable? (Blueprint Session result)

short arrow
#

Inside of the bomb the server will start the timer to explode -> server will fire a multicast telling everyone the bomb telling clients to start the bomb expiring animation

frigid niche
#

How would a dedicated server handle loading and unloading objects / actors across a world for players who come into range?

thin stratus
#

If the objects need to exist the whole time then it doesn't load or unload, it just starts replicating them to the player if in range

latent heart
#

Yeah. The server just has everything loaded all the time.

real ridge
quasi tide
#

I just want nice things

thin stratus
#

There was some watch you could create to check who hit the breakpoint. But I can't find that anymore):

fathom aspen
#

I never tried it tho

verbal tendon
rose egret
#

where is the function that destroys PlayerState when player left?

woeful ferry
rose egret
#

I mean the exact place that calls PS to be destroyed

#

those function inside them they call lots of other functions

#

overload over overload

kindred widget
#

Pretty sure it's a SetLifespan call if my memory isn't failing me.

#

Might have been a timer. Can't remember.

#

CleanupPlayerState is one place. But I swear there was one in GameMode or similar that set a timer or lifespan for reconnects.

#

Ah. Yeah. AddInactivePlayer in GameMode's Logout.

rose egret
#

the problem is I did some change to keep player state when pawn leave the game, (to save his state after a while)
now I realized those dead PS stay in memory for ever

#

I dont know what,where, ... change I did

#

lol

kindred widget
#

GameMode already does that for you. GameMode, not GameModeBase. You could have just altered the InactivePlayerStateLifeSpan property

honest rain
#

Hello !
I have an actor in my scene that has an event 'generate' to spawn other actors. I set this event on multicast since I want actors to spawn both on server and on client. Actor in my scene is set to replicate and the components in it as well.
I am calling this event 'generate' in my game mode by finding all actors from class and calling it, it generates fine on the server side, but not on the client side, why ?

quasi tide
#

Just spawn your replicated actor on the server. Unreal handles spawning it on the clients.

#

And what is calling this? GM is on server only.

honest rain
#

I’m not spawning the generator since it exists on the map already. At first I wanted to just run the generation in begin play of the generator, but I can’t cast to the game mode and I need it :/

real ridge
honest rain
#

So I figured I will just call the generate event from the game mode and replicate

winged badger
#

there is no need to bother the game mode, unless you need it to push spawn parameters

honest rain
#

I need the game mode to get the player controllers

real ridge
#

u just need start points on map

#

and then override find start point or player start idk name in game mode

#

that's all there u will set where they should spawn and other will do engine

#

u don't need spawn and posses it's handled by ue

honest rain
#

Yeah but it only spawn from server, not for the client

real ridge
#

no no it should be both I have it same way bro

#

are u using character or pawn?

#

is your problem that when u run 2 instances u don't see each other on map right ?

#

after spawn

honest rain
#

Yeah the players see each others. What I am trying to spawn is just an actor

real ridge
#

hmmm additional?

#

after game is in progress already ?

#

right?

#

and what is that actor?

#

it's a player or cube or something else

honest rain
#

Yeah it’s an actor, and it is supposed to spawn other actors as well through an event

#

Spawn works only for server, but not for client, except if I put everything in begin play, which I don’t want

quasi tide
#

All you need to do is have the server spawn the actor and have the actor set to replicate. You don't need to do anything else. Unreal will handle spawning on the client

#

You don't need the controllers. You don't need a multicast. You don't need any of that.

#

Just spawn the actor on the server.

honest rain
#

So an already existing actor in a map ( before play ) won’t be replicated, except if it is spawned by the server ?

quasi tide
#

What?

honest rain
#

If I have an actor in my scene, then I launch the game, it won’t be replicated for the client even though it is set to replicate ?

quasi tide
#

If the actor is set to replicate (bReplicates = true or the checkbox in the detail panel "Replicated"), it will replicate.

honest rain
#

Yeah that’s why i don’t get why only the server sees it, and not the client

quasi tide
#

Send code.

#

This is exceptionally basic functionality of Unreal. If it was broken, pretty much every project in Unreal would be exhibiting it.

real ridge
#

i still don't understand what should that spawned actor do you should be able to play with him?too? send your code of spawning

honest rain
#

this is my event, living on an actor in my scene, present at begin play

#

this is where I call this event, from my game mode

#

only the server has the event working, not client

real ridge
real ridge
honest rain
#

this event is in an actor in the world

real ridge
#

you doing it bad

#

okay

honest rain
#

definitely calling it in my game mode

quasi tide
honest rain
#

even when set to run on server or multicast, only server registers it

honest rain
quasi tide
#

Look - if you don't want to do things the right way, then you do you.

real ridge
# honest rain this is where I call this event, from my game mode

okay make 2 custom events one server only one multicast then make spawn on multicast, call server spawn- from server spawn call multicast from multicast call "spawned", then go to the player character make get game mode -- cast to the game mode call server function for spawn from there

#

done

#

clear ? 😄

#

you need call game mode function for spawn from character to game mode

#

and make spawning on game mode

#

and from game mode multicast spawning

#

just call that spawn function from your player

#

simply cast to game mode and call it

honest rain
honest rain
real ridge
#

I am little bit worried that i dont understand in general what your idea of it is 😄

#

how it should work what it should do

honest rain
real ridge
#

I will try describe what you want to do, you are on map playing/running right ? then for example you want press button SPACE and immediately it will spawn some "character" on map but for everyone

#

right?

honest rain
#

No not really

real ridge
#

then tell me please 😄 I will better understand

honest rain
#

I am on the map, there is a generator actor on the map that was there from the beginning. I want to call an event existing in that actor, and I want that event to be replicated to both server and client

real ridge
#

and what should new spawned actor do ?

#

just be there ?

#

do you want posses him or play with it?

honest rain
#

nothing gets spawned yet, for now I just want to have that event firing for server and client

real ridge
honest rain
#

ok thank you, I am going to try what you said to me

real ridge
#

try but my english explanation is not best haha

twilit radish
honest rain
#

so If I make the call from the player controllers which exists on both server and client, it should work

real ridge
#

not sure

twilit radish
#

The server can call a method on a different actor that is replicated, which in return that actor will do the networking part. The gamemode only exists on the server and can't do anything regarding networking directly.

honest rain
#

Ok I see

#

it worked when calling the event from the player controller indeed !

real ridge
honest rain
#

sure !

real ridge
#

my old machine still loading ue

honest rain
#

this is on my third person character

#

this is on my player controller

#

the event 'create' is set to multicast

real ridge
#

yes

honest rain
#

and now both client and server gets the same result, which is perfect

real ridge
#

so you dont even need game mode now

#

😄

honest rain
#

yeah I was stuck in this idea that because game mode is server side, it can decides to spawn things for the client as well

real ridge
#

to be honest working with multiplayer few months and I still dont understand it kekw

honest rain
#

Actually what I am telling you might be wrong, I already did a function spawning random loot from the Game mode.. so it is definitely possible

#

oh god my mind is lost

twilit radish
#

It can totally spawn things for the client if it spawns an actor that is set to replicate but it can not directly contact the client by it self.

honest rain
#

I see ! so In the same idea, no client can contact directly the game mode as well right ?

#

except through controllers ?

quasi tide
#

At all.

#

It is an actor that only exists on the server

#

Client can try and get it all it wants. It simply does not exist.

twilit radish
quasi tide
#

You have to run a server RPC to do anything with the gamemode. But clients really shouldn't be worried about that.

real ridge
#

ah guys I did some wrong call server/multicast and i cant run editor now it stucked at 75% fck what should I do it happened to me before once i had to revert changes but I dont want lose these

#

idk why its causing ue editor crash

honest rain
#

did you try to launch the editor without loading any projects ? to see if the issues comes from your project ?

#

Thanks for your help guys btw

real ridge
#

75%

#

😦

#

i had same pproblem before

#

i reverted changes and saved them

#

now its ok

#

ahhh weird

#

can do it from scratch

winged badger
#

Editor doesnt rpc at startup

honest rain
#

its at 79 and was 75 before, maybe compiling shaders ?

winged badger
#

Most common cause is incorrect number of uses of ConstructorHelpers

#

Correct number bring zero

real ridge
winged badger
#

But when that happens it will no unfreeze

real ridge
# winged badger Editor doesnt rpc at startup

I swear once we wanted to do respawn my friend called RPC call in pawn and it got stucked every time he deleted that blueprint and resstored old it started fine after he did same part of code again stuck on startup

#

we tried it like 10x

#

it was caused by rpc

#

i dont understand why

winged badger
#

If you have s lot of textures, shaders, etc... you might need to increase the size of your derived data cache in baseengine.ini

real ridge
#

maybe thats problem

#

(Dobro došli) XD

winged badger
#

Its a config file in your engine folder

real ridge
#

DefaultEngine.ini?

#

not base I except

winged badger
#

But you can tell if editor is building textures every time xou start it

#

Base

#

Default can override settings, but youll still need to luft them from baseengine

real ridge
#

cant find it in

winged badger
#

Search maxsize=512

real ridge
#

mby this?

#

maxsize no there

winged badger
#

Hmm, no

#

Not near pc atm

real ridge
#

let it be I am going to make again blueprints I had and then show what causing my crashing

#

I bet it some RPC call

winged badger
#

Not before you hit play

#

No RPCs without that

real ridge
#

I know but believe me its causing it I will show you

#

...

#

can I run log somehow with startup?

winged badger
#

You can go to you engine install option and add editor sybils for debugging

#

Then s crash eill generate a readable callstack

#

That can be used to diagnose the ptoblem

real ridge
#

so i found problem

#

its in my player pawn

#

when I delete it it will start project

pastel escarp
#

How do I decide what is a good net update frequency for my game ?

real ridge
#

guys when I want cast to player state in my player it will fail if I will not put delay before it why? its like its not loaded

thin stratus
#

That's what Ping and Replication is all about

#

Delays should never be used to fix this

#

That's what OnRep/RepNotify is for

real ridge
#

when to do it then or where

thin stratus
#

BeginPlay of what?
Generally BeginPlay is probably too early

real ridge
#

in player state its allright? 😄

thin stratus
#

But that's not your PlayerState

real ridge
#

its working now

thin stratus
#

That will set the Server's Name to all Players though

#

BeginPlay calls on all Instances of the PlayerState

#

So also on Server

real ridge
#

I am setting name there and then using widget to show it

thin stratus
#

And since Replication is Server -> Client only, that PlayerNick is gonna be set by the Server

real ridge
#

yes

#

so now its prolly fine?

thin stratus
#

:D I just told you it's not fine

real ridge
thin stratus
#

You have to limit the BeginPlay call to the local client

#

Otherwise all your PlayerStates will get the Server's Name

#

And you have to do that with an RPC

#

Because the Server otherwise doesn't know about the name

#

You should also use the GameModes "ChangeName" function to properly override the PlayerName variable that already exists in the PlayerState

real ridge
#

problem is idk where now set player state name as I cant do it on begin play 😦

#

i can use custom event but it will be also called on begin play

#

and event tick si nonsense

#

or I got idea

thin stratus
#

BeginPlay -> GetOwner -> IsValid -> CastToPlayerController -> IsLocalPlayerController -> GetGameInstance -> CastToYourGameInstance -> GetPlayerNickName -> ServerRPC(PlayerNickName) -> GetGameMode -> ChangeName(PlayerNickName)

real ridge
#

what about this

thin stratus
#

That won't work if you have no pawn

#

I just told you what to do

real ridge
#

okay

thin stratus
#

GetOwner will filter Simulated Clients, as the Owner of the PlayerState is the (Player)Controller and that is null on Simulated Clients.
IsLocalPlayerController will ensure that the Server doesn't call this for non local Players.
ServerRPC is needed so the local client can tell the Server about the Name.

thin stratus
real ridge
#

hmm ? still not finish

#

its good till now?

#

idk if I need rpc because name is already set as replicated 😄 and I am getting this name in widget so propably not? 😄 not sure

#

kek u were true i generated random numbers there and they are same for both so I will try add rpc kekw

pastel escarp
#

I guess it is better to use OnRep_PlayerState ?

thin stratus
#

Yeah but that is not available in BPs

real ridge
#

idk I am lost XDDD

thin stratus
#

Uff

fathom aspen
#

Can I call this deja vu at this point?

pastel escarp
real ridge
fathom aspen
#

Like every time I passed by today I see the topic of names being dicussed

#

With you

real ridge
#

I am keeping this discord alive

#

:DDDDDDDDDD

thin stratus
#

They are still lacking the basics

#

Which is honestly, at this point, a joke

fathom aspen
#

I know Cedric

real ridge
#

trying my best

fathom aspen
#

You and some other smart people here have helped them but all in vain

#

It's a headache at this point

real ridge
#

idk I red compendium like 5 times but maybe I am just dumb

#

that its not working

#

every time..

fathom aspen
#

Sorry @real ridge but this is the truth

real ridge
#

u not hurting me

#

I know i am ..... dumb

thin stratus
#

If you read the Compendium 5 times and you still don't know why you need the RPC here, then idk anymore

#

This is nothing anyone here should be spending time on tbh

real ridge
pastel escarp
#

multiplayer concept is a bit tough learning curve, but you will get instantly with Trail and error

real ridge
#

without nothing

thin stratus
fathom aspen
pastel escarp
#

just give it a bit time

thin stratus
#

Which you need the RPC for, cause if you set it locally it is not replicated...

real ridge
#

i am just trying

#

to not give up even I am lacking

thin stratus
#

It's not about annoying, but you have to learn this stuff eventually

#

You can't ask questions that boil down to the same basics being lacking all the time

real ridge
#

I get it sorry

#

I dont want ban

#

😄

thin stratus
#

Why would you be banned for this?

graceful flame
#

Use RPC when the event is originating from human input. Someone playing your game pressed X and it needs to send something over the network because the server doesn't know that event happened.

thin stratus
real ridge
#

I am going to read and watch some useful materials and try everything by myself again

#

It was big miss that i thought if variable is set replicated I dont need rpc then anymore bcs its replicated LOL

graceful flame
#

@real ridge Something I found very useful when learning multiplayer was to use breakpoints in my blueprints so I could easily tell if the process was currently the Server or Client. It takes a lot of the guess work out.

graceful flame
#

Have you used breakpoints before?

real ridge
#

when I coded sessions

graceful flame
#

Just press F9 on any blueprint node to add the breakpoint (red stop sign) then play your game and when the breakpoint is triggered it will pause. Then press F10 to continue node by node and F11 to enter into a function or event.

quasi tide
#

Honestly - doing super simple and basic stuff in BP many times is what helped me. Whenever you are in a function and you are writing it - think about what is the context of that function; IE - what machine is this going to be running on?

real ridge
#

ah thanks

#

and again sorry guys

#

I feel bad now

#

....

quasi tide
#

Visual Scripting is pretty good at conveying the flow of execution imo.

quasi tide
#

When I write a function, I think to myself "alright, this is called locally and it needs to run on the server. So I need a Server RPC". Then when I start writing the server RPC, I think, "Okay - I'm now on the server, so I have access to w/e I need"

#

So on and so forth.

#

Think in the context of the machine that the function will be running on.

real ridge
#

yes

quasi tide
#

Once you get used to this aspect - and you follow the basic principle that is "Server is the REAL instance of the game and the clients are ideally, just a viewport into that" - things become like 2nd nature.

#

Now of course that is just a broad concept. You can fine tune it to do some things locally.

real ridge
#

i am trying debugging of blueprints now and going from one blueprint to another but is there also some log for it ? or I just can watch what is game doing one by one blueprint?

graceful flame
#

With a breakpoint?

real ridge
#

yea

graceful flame
#

I usually just set one breakpoint at a time because I'm testing one thing at a time. For example why didn't the ammo value change after picking up the ammo box?

real ridge
#

ah shit some things messed up my project and wont load

graceful flame
#

It doesn't print anything out, but you can hover your mouse over the pins and they show their current value in a tool tip, so if you have a breakpoint before some value is set you can see it before then F10 past the set node and hover the mouse again over it to see the new value.

real ridge
#

ahhhh nice

#

thx

real ridge
graceful flame
#

What do you mean?

#

When your game is running and you have a breakpoint setup go back to that blueprint and look to the right of the pause and stop button where the dropdowns are. I usually leave it on "All Worlds" but the second dropdown is important, if it says "No debug object selected" then you can do whatever happens in your game to trigger the breakpoint and it will pause and show with large yellow text if its currently the Server or Client. If you have multiple instances of the blueprint you're debugging then use the dropdown to select the specific instance of the object.

real ridge
graceful flame
#

It says it on the top right of the graph

#

See on this first screenshot its running on the client because the input happens client side when I pressed X on my keyboard.

#

and here on the second screenshot with a RPC it says its running on the Server

#

and I'm running the game in PIE using Play As Client mode by the way

little cipher
#

Hey everyone!
I'm pretty new to unreal networking and have a potentially stupid question.

my goal is:
each player (client or listen server) can shoot a rocket with a projectile movement component that will explode when it hits things. pretty straight forward

i tried various setups that kind of work:

#1 when i fire i call the server to run a multicast and spawn non-replicated rockets with the same initial positions and velocities
pros: nice cause they all are evaluated locally and 'smooth'
cons: small but very annoying lag before my rocket appears on the client side

#2 i spawn a replicated rocket (+replicated movement) on the server and it gets spawned on all clients
pros: all positions are sort of in sync
cons: can cause jitter in the trajectories and has the delay

now i don't care too much about the rockets themselves and their positions (the explosions that matter will be run and broadcast from the authoritative server) but care that the gameplay feels good. so what i would like to do but am not sure how to best approach is the following:

#3 spawn a local rocket and tell the server to multicast a spawn even to all clients (kind of like #1, but with the addition of instant feedback on the local client)
pros: client feels great and all other players get only the slightly delayed event
cons: local client is obv slightly 'ahead' but that doesn't really impact the gameplay as only the explosion matters

but that brings me to my problem: how do i set this up? if the server spawns it for clients i get it also on my local client which makes two rockets. it's probably something simple i am missing, but it's really breaking my brain.
i am working only with blueprints for now

pastel escarp
#

Any idea why net pktlag isn't recognised ? am I missing smthing ?

Cmd: Net Pktlag = 100
Command not recognized: Net Pktlag = 100
twilit radish
#

I can't find a command for it either honestly, the way I always do it is through the editor preferences. If you click on the little menu next to the play button in the editor and click "advanced settings" then you can set emulation profiles for packet loss, latency etc.

graceful flame
pastel escarp
twilit radish
#

You can also set them in a .ini somewhere.

pastel escarp
vapid sleet
#

Hey guys,
If I call a Server RPC whats the way to identifiy the client who called it?

graceful flame
#

Search for NetEmulation in console there's some there yea and even an on/off command

pastel escarp
twilit radish
# little cipher Hey everyone! I'm pretty new to unreal networking and have a potentially stupid ...

Definitely not a stupid question. But to my knowledge there's generally not a 100% proof solution. Predicting it will always have some issues because server/clients are never perfectly in sync and then you also indeed get the issue that the server lags behind because of latency. There's also the solution of predicting at first and then as soon as the server rocket gets replicated to your client destroy the predicted client and try to smooth out the difference. Depending on how fast your rocket is I would honestly just choose server authority to prevent the issue where prediction is off and turns into a "But what on earth? I hit that!" moment and it's so much easier to deal with.

twilit radish
vapid sleet
#

Okay Thanks @pastel escarp & @twilit radish

kindred widget
#

Yeah. If you need a player state or a controller, you can always walk up the ownership chain til you get something that has access to it easily or straight to the controller itself.

pastel escarp
mellow stag
#

So I’m hosting a dedicated server and the server starts to lag with 20+ players but the memory on the computer in task manager is barely being used

#

Any reason why that’s the case?

little cipher
# twilit radish Definitely not a stupid question. But to my knowledge there's generally not a 10...

yeah that makes sense.
The 'deleting the client rocket once the replicated rocket comes in' solution could work well (esp if it's somewhat hidden in a launch effect) but how would i go about implementing this?
In a perfect world i would be able to spawn a rocket with a unique name and the replicated projectile just replaces it once it comes in...

I did set my setting on my listen server launch from editor to not very great so the effect might be more pronounced on those simulated clients too, but replicated movement is really choppy (hence my thought of doing most of it locally to save bandwidth in #1)

kindred widget
twilit radish
real ridge
#

❤️

dark edge
#

It feels a lot worse to miss when you should have hit than it does to get hit when you should have not gotten hit.

twilit radish
dark edge
twilit radish
#

Oh wait nevermind, misread your message lol.

dark edge
#

That's what I'm doing for my game but it's slow paced. Could never do a Counter-Strike like that

little cipher
# twilit radish Could probably simply keep track of an incremental ID client side for all rocket...

i tried just this right now and love it.
now the client just creates it's own rocket and send an MC to the server which tells everyone to spawn their own (local) rockets
the MC checks if a rocket with the provided ID exists and just skips the spawn when it find one (keeping the local rocket alive)

yes there is a slight discrepancy between the one client that originally spawned the rocket, the server and all the other clients (the offset gets worse in that sequence) but the explosion will be run authoritatively on the server so it's really just the visual that is important. Trajectory and speed are identical on all machines

this is exactly what i was looking for and allows me to modify the client/server behavior pretty flexibly

thank you!

twilit radish
# dark edge That's what I'm doing for my game but it's slow paced. Could never do a Counter...

But then again, if you're making the next Counter-Strike you're very unlikely to be in this channel anyway 😛
Not sure I agree with you though, if you just want to get it over with. Definitely server auth I would say, if you have some more time on your hand I would just go for the option to predict first and then turn into server auth.

At least assuming we care about cheats that is.

If we don't care whatsoever about cheats I would let the client determine the position of that rocket. Can never miss. But I think I would still prefer the predict to server auth honestly.

serene furnace
#

Hello hello

I have a question about how I should check a player status.

In my case, I have several occasions that triggers a bleeding, and player is loosing health over time when bleeding Boolean into the player status component is unable, thing is I dont really know how to trigger the check again and again, what is an effective way of doing that ?

Just asking the server to refresh the player status every 5 sec ? Cause you cant for sure use any delay into function, and my trigger is into a function, so no way to use that again to keep looping a delay.

dark edge
#

Here's the core of the problem. Clients A and B have the same ping and both start running forward at the same real time. This is what they see.

twilit radish
serene furnace
twilit radish
#

I mean I suppose. I don't really see how else you want to have an effect every so often without some kind of timer. But I don't see why the client should check the status. The server should tell the client that they are bleeding.

dark edge
#

A bleed could be an actor that ticks damage on its target

#

or it could be just some data in a StatusEffectComponent

#

or it could just be a GameplayEffect if you use GAS

serene furnace
rich furnace
#

When I click my test "play" button, it takes me to a different level (my main menu level) when my Open Level (by Name) has the Level Name I want it to open. I have to click the button again to open the desired level. I re-did the session with new game instance, widgets, and was still going it. In PIE and stand alone it does it as well

mellow stag
novel siren
#

Hopefully a quick one.

In C++ I am trying to resize (using SetNum()) a replicated TArray in an UActorComponent. The component, and the array, are set to replicate. The owning actor (player character for the test) is also set to replicate. It works fine enough with 1 player in dedicated (or listen) but the second player is added in, I get an out of bounds error (sometimes the error log names part of the struct that the array is holding, sometimes it doesn't. The part it names varies). If I do the resize in blueprint only (using the resize node and the array variable defined in C++) it works.

The only similar post I could find online about this was with someone forgetting to call super in one of the overridden methods (I am not overriding that method and I am calling super in all the appropriate places). Anyone got any idea what I might have overlooked?

dark edge
strong pond
#

Any great starting points for multiplayer (blueprints). I have basic understanding of replication , but not enough to implement it into my projects. Paid course or YouTube series doesn't matter

serene furnace
dark edge
#

or timer

serene furnace
#

Well ty ty I will look into those solutions and pick one

little cipher
#

I guess @naive dome is on here! Massive shoutout to the channel from me!
Thank you for the great videos 💜

silent valley
# mellow stag The cpu is running at like 20% and memory is at like 5%

You need to use the profiling tools, e.g. Insights, to profile the server, for both network and cpu. Dedicated server is almost exclusively single threaded so overall cpu usage is not useful.

If the single core is only 20% then it sounds like network limited. Insights will identify this easily.

twilit radish
#

I saw a video (or similar?) about someone mentioning a nice concept:
It's like skateboarding, you can go to a park and see others do it but your first times will never be as good as them no matter how much you watch them do it.

blazing spruce
#

Does anyone have any experience in setting up beacons to create a party system? I can barley find anything on them that explains how to set them up and use them properly without the use of dedicated servers, VPNs & port forwarding

errant vapor
#

is there any information on reliable RPCs anywhere? specifically, whats the interval between retry-attempts, how long does it keep retrying for, etc?

latent heart
#

Have you checked the compendium?

errant vapor
#

i have, it doesnt really go into detail at all about reliable rpcs

#

struggling to find anything but the official documentation on it, which also isnt very helpful

latent heart
#

Official docs going that deep just don't exist for anything, period

#

At that point they just expect you to read the source.

errant vapor
#

hmm i guess i hoped this one would be more common knowledge, since it would be nice to know how reliable a reliable function is

#

looking into the replication source sounds both difficult and exceedingly time consuming

blazing spruce
errant vapor
#

that sounds reasonable, but it opens up for questions like... does it give up after eg 60 seconds or does it continue indefinitely? how often does it try it? every frame or every 500ms? only when that specific actor does a net update? is it the same to and from server?

blazing spruce
#

I don't think there's like a time limit or anything so it'll just keep attempting it until it eventually gets through which is why its important to only mark events reliable that need to be reliable instead of making all event reliable

#

I also dont think theres a specific time limit on when it'll retry cause i imagine this could be down to things like packet loss, network bandwidth ect.. so i dont think theres a set time on when it gets re-attempted

#

I could be wrong tho lol

twilit radish
#

--- Resending Missing Data ---

As mentioned above, packets alone don't contain useful game data. Instead, it's the bunches that comprise them
that have meaningful data.

Bunches can either be marked as Reliable or Unreliable.

The engine will make no attempt at resending unreliable bunches if they are dropped. Therefore, if bunches
are marked unreliable, the game / engine should be able to continue without them, or external retry
mechanisms must be put in place, or the data must be sent redundantly. Therefore, everything below only
applies to reliable bunches.

However, the engine will attempt to resend reliable bunches. Whenever a reliable bunch is sent, it will
be added to a list of un-ACKed reliable bunches. If we receive a NAK for a packet that contained the bunch,
the engine will retransmit an exact copy of that bunch. Note, because bunches may be partial, dropping even
a single partial bunch will result in retransmission of the entire bunch. When all packets containing a bunch
have been ACKed, we will remove it from the list.

Similar to packets, we will compare the bunch number for received reliable bunches to the last successfully
received bunch. If we detect that the difference is negative, we simply ignore the bunch. If the difference
is greater than one, we will assume we missed a bunch. Unlike packet handling, we will not discard this data.
Instead, we will queue the bunch and pause processing of any bunches, reliable or unreliable.
Processing will not be resumed until we detect have received the missing bunches, at which point we will process
them, and then start processing our queued bunches.
Any new bunches that are received while waiting for the missing bunches, or while we still have any bunches in our
queue, will be added to the queue instead of being processed immediately.

#

This is probably the best you'll get without looking through actual code I suppose.

#

Also have to love them writing a million lines of explanation in that header for it only to not show up in the docs.. :p

errant vapor
#

thanks, theres definitely some interesting stuff in there

quasi tide
#

It's also not common knowledge because it isn't common for people to really care about that. All that really matters is that a reliable RPC is guaranteed to be received. It keeps trying until it does.

real ridge
plucky prawn
raw thunder
#

Hello everyone,
I have a question about the function GetController<APlayerController>() used in PawnComponents.
In the Lyra project they use it on clients and it returns an actual controller (for example in the LyraHeroComponent). However when I use it in my project it returns a nullptr (only on clients) (as said in the function description: "/** Gets the controller that owns the component, this will usually be null on clients */")

Why is it not null in the Lyra project?

thin stratus
#

It's null for simulated clients.

#

It will be valid for the local client and the server

#

If that's not the case on your end then you have a bug compared to lyra

raw thunder
real ridge
# thin stratus It's null for simulated clients.

hello I finally did names I red again compendium and tried it but I want ask I used repnotify and I combined it with RPC it is fine solution to have server call and multicast call combined with repnotify?

dark edge
real ridge
graceful flame
#

Use multicast to spawn a sound effect or particle system. Something that isnt a big deal if it fails. If a player joins the game after it happens they won’t receive the multicast.

Use Repnotify for when variables change and everyone needs to be kept in sync with the update. Even players who join after a repnotify happens will still be updated.

real ridge
#

In player state I am going to SwitchHasAuthority --> remote ---> cast to MyPlayerPawn--->SetPlayerName(function called on server) + pass nick from player state to it---> SetPlayerName(function called multicast) ---> set nick name (rep notify) and in rep notify I am setting name in widget

#

and its working

#

without errors

graceful flame
#

Oh my

#

Too much back and forth you don’t need to do that. Player State is already shared on client and server. Look at the diagram with the circles on the compendium.

real ridge
real ridge
#

and as I dont see any errors I will stay with it propably 😄

#

I am getting player nick from game instance in player state then set it to player state nick which is replicated and passing to function which is in pawn

#

working perfectly

#

debugged it and checked logs no erros at all

#

so

graceful flame
#

Have you tested if it works when you start with one client then press add client while the game is already running?

real ridge
#

so it was successful I think

#

immediatelly when I pressed F player got new nick on both clients

#

and everyone saw it

#

when I didnt use multicast only server got new nick after F press I tried run (one listen server and one client)

graceful flame
#

You don’t have to package to test late joiners

real ridge
#

so then I added multicast and vuala

real ridge
#

then

graceful flame
#

I told you

#

Start with one client then once you’re playing press the add client button

real ridge
#

i am looking for that button

#

lol

graceful flame
#

Near pause and stop

real ridge
#

I am blind?

graceful flame
#

What net mode are you using?

clear island
#

search for late join in editor preferences

#

you need to enable it

graceful flame
#

Ohh that could be

real ridge
graceful flame
#

Ok

real ridge
#

ah I allowed late joining

#

now

#

ok gonna test

clear island
#

play as listen server, then add clients as needed

real ridge
#

so when I added another clietn

#

he loaded name

#

unfortunately they have same name as there is only one name in game instance

#

but I can test it by generating random int as name in player state and set it

#

give me sec

clear island
#

yea thats what I do

#

I check if im playing in the editor and if true, generate random name

real ridge
#

working perfectly

#

i see name of new joined he sees mine

#

so repnotify + rpc is my only solution finalllyyyyy

#

was trying this 1 fking week

#

😄

#

its fully replicated

#

YES

#

@graceful flame check

#

added 5 players all had right name and all saw same names

#

no problem no error

#

no lag anything wrong

graceful flame
#

I think your set player name client multicast doesn’t have to be a multicast can a regular custom event with has authority > authority. It’s doing extra work but does the same thing yea.

real ridge
#

i dont get your advice

#

can you better explain

#

I can try comment and try it with your idea 😄

graceful flame
#

It’s important to reduce the network traffic as much as possible because as you add more and more features to your game the way you go about passing data over the network needs to be efficient.

real ridge
#

i understand where I can check how much is network used ? and if I need something change

#

do you know what I mean

graceful flame
#

I’m glad you managed to get it working and would suggest you fully understand how and why it works as it does and try to see if it’s doing anything more times than it has to.

#

You can use the net profiler there’s a video epic made showing how to use it.

real ridge
graceful flame
#

Don’t have to use network profiling too early on with your project but it’s good to know that it’s a tool that can be used when the time is right.

real ridge
#

so I suggest it maybe is good but then I am facing question do I need server call to custom event with switch has authority?

#

I dont think I can set repnotify right after server call

#

without uselles another custom event

#

Bad idea?

graceful flame
#

The custom event can be running on the server and client both it depends where it was called from in the first place.

#

The switch has authority lets you split them

real ridge
#

i know as I understand good remote -- means it allow call only on client and remote it allow call only on server

graceful flame
#

Run on server is only used when you know for sure it’s running on the client but needs to happen on the sever.

real ridge
#

i am just saying SetPlayerName is calling on server from it I am calling SetPlayerNameClient which is just custom event and there is switch authority which is set nick only on server as there is Authority connection so I just can set nick/name after SetPLayerName

#

do you understand orr? XD

graceful flame
#

Such as player input

#

But an overlap or hit can run on both client and server so you use has authority to make sure the important game play logic is checked on the server to prevent cheating

real ridge
#

ok so I f I use only one node of switch authority the code will execute only on that side which I will choose there

#

right?

graceful flame
#

Can also use Run On Client which is when it’s currently the server processing stuff but you want something to happen only for the current player such as spawning a widget or playing a sound only they can hear.

graceful flame
#

Otherwise there’s no point in doing has authority check in the first place, just slowing the game down a tiny amount.

#

For example you don’t have to check authority for the GameMode because that only exists on the server. And you don’t have to check has authority remote for a widget because that only exists on the client.

real ridge
graceful flame
real ridge
#

so destroy player should be called on server only or damage?

#

hmm

#

this is how I am doing damage now

#

with native events

#

should be fine 😄

graceful flame
#

Use EventAnyDamage and check the math after damage against replicated heath value and if it’s less than or equal to 0 then change a replicated boolean for dead

#

You don’t need server apply damage the icon on Apply Damage is already doing that for you

real ridge
#

yes thats why I used those so its fine aight?

#

when I check its 0 I just destroy actor

graceful flame
#

That’s an unnecessary rpc

real ridge
#

why is mp so complicated and it seems so easy for first time

#

kekw

graceful flame
#

See that computer icon with a lightning bolt? That means it only runs on sever. The widgets have a different computer screen icon that means runs on client only.

graceful flame
#

I’m looking forward to trying your game one day.

real ridge
#

hopefully

near granite
#

Is there any way to set the world origin rotation?

dark edge
# real ridge looks like this :3

Something like player name should just be a repnotify and that's it.
Client -> Run on server event -> Set replicated variable -> Everyone runs repnotify.
No multicast events

dark edge
graceful flame
raw thunder
#

Hello everyone,
My client pawn does not have a controller on the client side but it does on the server side.

How can I debug this? I followed step by step from PostLogin() to FinishRestartPlayer(), the server side seems to be fine (the controller has the pawn, I don't know what I should really check...).
What can I check on the client side?

foggy idol
#

How do I get the latency from a client to the server ?

real ridge
upbeat crystal
#

I'm very confused

in UE5 in editor your able to join a session with online sub system but in the package project you can not join I have 2 steam accounts on the same network i need a solution why i can not join sessions in package game do you have to add something else to the config file I added the required stuff for steam app id

raw thunder
upbeat crystal
upbeat crystal
#

another thing when i click join it keeps on sending me back to main menu after join session why?

twin juniper
#

Probably a basic question but if I use an interface functions instead of custom events that replicate on the server, doesn't that mean that the interface functions aren't replicated or if they are, that they are a security risk?
Mainly asking because I have different actors that inherit from 2 different base classes, but have a lot of similar functionality. Was trying to see if I could clean up the code base

jovial charm
#

Hey guys in the unreal documentation it says you can set the "Replicates" property for an event or a function, but I am unable to find the "Replicates" dropdown in my function, am I doing something wrong?

thin stratus
#

Hm no, in BPs this only works for events

#

Functions can't be RPCs

thin stratus
prisma snow
#

I'm setting a struct variable to be replicated and I'm not sure this is supported in the first place:

UPROPERTY(Replicated, ReplicatedUsing="OnRep_TeamInfo")
FRTSTeamInfo Team;

// later

UFUNCTION()
void OnRep_TeamInfo(const FRTSTeamInfo& NewTeamInfo);

The problem is that NewTeamInfo is always empty (struct build with default constructor). Probs I'm doing something wrong

thin stratus
#

You only need ReplicatedUsing

twin juniper
thin stratus
#

And the param of an OnRep is the old value, not the new one. The member variable itself will be the new data.@prisma snow

twin juniper
#

Unless the original call was on the server and then I used the interface as a middleman to call the event on the individual classes?

prisma snow
#

too much RPCs lately

#

forgot how replicated vars work, thanks a lot

thin stratus
#

Interfaces themselves are just normal functions

#

Not sure what you mean with safe

twin juniper
#

Well if a class uses the interface function to remove hp, then if the call to the interface doesn't originate from the server, then couldn't this open up a path for cheating?

thin stratus
#

Why

twin juniper
#

Because couldn't someone call that function?

thin stratus
#

That's always the case

#

No matter if interface or not

#

Again interfaces just provide normal non-networked functions

twin juniper
#

Oh you mean someone could call the run on server custom event anyway if they say, find a way to decompile the source and add a cheat

thin stratus
#

You should never have an RPC to deal damage in the first place.

twin juniper
#

How should you deal damage then?

thin stratus
#

By only using the RPC at the start of whatever chain of events leads to damage

#

E.g. a left mouse button press that fires a weapon

#

You only tell the server to fire the weapon. The rest is server side then

real ridge
#

fast question can I cast to game mode from player controller? or call server from there or its fully client side?

thin stratus
#

Including the resulting damage

twin juniper
#

The way I have it working right now is that the ai controller issues the attack command. The actor plays an animation, and when the animation is finished, it executes the receive damage event on the target actor, which is marked "run on server"

#

I don't think you can call the game mode at all from the controller

real ridge
#

okay will use player state

#

thx

thin stratus
crystal crag
#

eXi - were you the one that told me that you typically use in-place animations but apply root motion sources for your games?

twin juniper
#

I tried that recently @real ridge and I had to replicate the data to the game state instead

real ridge
#

o bcs I was trying call function

#

and its failing

#

😄

thin stratus
#

Yeah cause the GameMode doesn't exist on clients

real ridge
#

okay

thin stratus
#

Multicast makes no sense in a GameMode

real ridge
#

player state will solve it

thin stratus
#

GameState probably better then

real ridge
#

u saying it to me? i am not doing rpc in game mode

twin juniper
#

So okay, where would I have the function that removes hp from the actor then. Like which class should that function exist on?

crystal crag
#

I have been trying to do that, and it works well, except for one small (yet big) caveat

crystal crag
#

and maybe I need to use a different node

#

but when it comes to handling rotation, when using ApplyRootMotionConstantForce, it simply doesn't handle rotation

twin juniper
#

Honestly idk, I thought that anything I wanted to replicate correctly had to be run on the server

thin stratus
#

No

twin juniper
#

I didn't want a client running that function, so I set it to run on server

crystal crag
#

it (mostly) statically applies single motion and never adjusts

#

Above is playing real root motion w/o root motion source

thin stratus
#

You only use RPCs if you want to move from server to client, client to server or server to all

crystal crag
#

and the second one is playing same animation w/o RM, but using ApplyRMConstantForce

#

the top one (native RM) seems to adjust to my rotation

real ridge
#

player state working perfectly!

twin juniper
#

Okay, so as long as the variable (current health) is set to replicate, it doesn't really matter if the function is set to run on server?

crystal crag
#

the second one, if I turn, then I move backwards

#

like I am moon walking

#

I am not sure how to deal with it

thin stratus
#

The rootmotion of that anim as a montage is just fine

twin juniper
#

@wheat portali does the animation blueprint run on the server or client or both?

thin stratus
crystal crag
#

Well I was trying to build an ability that could intelligently switch between RM and non-RM, depending on how close the player is to the target

#

That way the player wouldn't try to walk over the other player as they were attacking and right up against them

thin stratus
#

I did that in a Singleplayer game where I had a AnimNotify that executed root Motion Source and turned off normal root Motion for the time to get close to a target

#

Not sure that works in multiplayer

crystal crag
#

Well right now I am just playing it in the editor

#

I'm just trying to figure out which source I should be using or high level what approach I should try

#

then I can see if it works in multiplayer

#

How did you solve the movement going against the rotation of the player?

#

I don't see any root motion source that accounts for this

real ridge
#

guys sorry but how i can get that controller ? its on server and i tried get actor from begin overlap then get owner and put it in cast but not working

#

its failing

real ridge
#

and fixed

#

get owner not helping

#

i need current player who is overlaping and send his controler to game mode to check who picked bomb

#

i can send actor but i dont know how to get controller from actor in game mode to check who has bomb

#

tried this in game mode to get actor from controller but failed

thin stratus
#

The Overlap should also happen on the Server. No need to send anything to it

#

If at all you just limit it to server via SwitchHasAuthority

real ridge
#

doing it I just wanted send

#

that player reference who overlaped

#

to game mode

#

and there check if he had ?bomb boolean true

thin stratus
real ridge
#

my loop is just looking in my array of player controllers and checking who from them have ?bomb true and if he will find it

#

it will tell me

#

thats why I wanted pass reference to that player to game mode

crystal crag
#

oh ok

real ridge
#

try it via function?

graceful flame
real ridge
#

hm I am just now thinking if my solution of bomb is good when I pick it I am trying to get position of base 1 and base 2 in game mode and then find out which player picked bomb and then I am trying to apply damage