#multiplayer
1 messages · Page 56 of 1
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
your gamemode has the login string
it also has RenamePlayer or something very similar function
i have this login screen
game mode is also restarted when you join session i think
anyways if I tried this with player state instead of variable ina playerpawn it will work?
if its hard travel (connecting to a different server) you can provide the name via login options
its joining the session from offline to online status
if its inter-server travel, PS will copy the name to the new instance
idk how to explain
also, as Jambax mentioned, replicating FText is bad, FText is there to handle localizations
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
you mean bind text is bad?
what I did
all UMG bindings are terrible
but if you have to replicate text, replicate a string
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
playerstate will survuve anything pawn will
i will show you
or controller
btw where u from why u have nick zlo
croatia
cool i thought u from slovakia its like our word
i saw u have snow now in croatia
heh
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
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
that is called seamless travel
Not going to be able to say this soon with ModelViewViewModel. 😄
I still love writing that name, it never gets less ridiculous.
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
Cause you're setting it from a mutlicast.
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
and?
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.
hm
so anyways I need store variable in player state
should I create variable name in player state and set it replicated?
PlayerName already exists in the playerstate. It's a native variable.
@real ridge
but its just id of computer or idk what u cant set it
as I know
I have nicks i cant use default code from pc
as player name
hm so like this?
dont i need some function which will always load all names of players in game?
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?
this was not working when I set it it was still empty
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
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?
Assuming Epic actually keeps working and maintaining it
Heyy
in mobiles
Is this enough to implement lan? like will player be able to play?
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?
Are you using CommonSessionSubsystem by any chance?
im using steam
The AdvancedSteamSessions plugin or whatever it is?
ye
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.
i would also like to know best practices, is the player suposed to destroy the session when he leaves or when he creates another?
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.
that CommonSessionSubsystem plugin is for 5.0 im still on .26 unfortunately
CommonSessionSubsystem? First I'm hearing of this honestly 🤔. Have I been asleep?
Oof. Fair enough. We backported it for 4.27, but Kaos did a ton of work on it.
i will keep it in mind for my next game
Ah - a Lyra thing
It's how Lyra loads it's levels too. You don't actually call OpenLevel anymore. You load a session even for singleplayer games, and the subsystem sends you to the new level after hosting the session.
isnt that overkill? lyra is the new default ue5 project right?
example project i mean
I've been using AdvancedSessions all these years. Been workin' well enough for me 😅
Stuff like this.
🤔 - feel like this could've been a GI subsystem most likely.
CommonSessionSubsystem is a GameInstanceSubystem.
I'm talkin' about UCommonGameInstance specifically
is there any node to check if there is an active session?
Am not immediately seeing one exposed to BP, not unless AdvancedSteamSessions has something.
i checked and didnt find anything
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.
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
Would need a callstack.
Walk up teh call stack
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?
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
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
This is quite hard to tell cause this log is missing symbols
That's why it's all UnknownFunction
Is this a packaged dedicated server?
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
So a ListenServer?
ye
Can you reproduce this crash?
yes
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?
its up there but i can take another one
let me just check if its because of the FString
Callstack is usually a lot longer
well i cut of the irrelevant parts, i know where the crash is coming from
I can tell you that it would probably crash cause of the line above that
the last thing it calls in my code is that fstring
The NewPlayer->NetConnection stuff looks more sus
makes sense, if its not initialized it would be putting grabage inside that fstring
It might just crash on accessing any of those pointers
Why do you even need that there?
i was going on the assumption that, that line was clear because its pointing to the one below it
Sometimes the callstack does indicate the next line for some reason instead of the nullptr line.
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
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
well, you shouldve been here when i spent a whole afternoon looking into that xD
Yeah Cedric. How dare thee
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
ye i know that now, i guess i will change it
makes more sense anyways
👍
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__));
i didnt even knew that function existed
Obviously "something went wrong" should be more descriptive
It's more or less c++ basics
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
It's when you venture outside of the C++ walls that Unreal has provided...that's when C++ gets top tier ridiculous.
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
Double ternarys are fun though. 😄
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
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
The attachment method has a RepNotify behind the scenes ^^
If you know a bit of C++ you can find more in the SceneComponent.h
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.
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...
how do I know its Client build ? whats the macro for that ?
I know UE_SERVER means v r compiling for dedicatd server
its still 0 in standalone isn't it ?
I want to exclude my server codes from client version only, not listen server or standalone
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
I guess there was another macro
You can check build configs inside Build.h
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.
Bottleneck in local resources
If your CPU utilization is maxing out, you will see rubberbanding
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
Uhm. Yeah on a threadripper you should be fine
unless you are doing something wildly crazy
what do you mean by lag ? low FPS ? use unlit mode if u have several PIE clients
Replicate Movement might be the thing doing that. Is it checked?
The elevator is your problem
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.
Replicate movement is not checked. I use server RPC calls to activate the elevator, the movement should be client side. But I'm checking out the profiler, there is something going on eating up system resources.
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
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.
I'd say it's over optimizing personally - especially if you haven't measured it yet.
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.
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.
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
the same way you pass them to any other function, assuming they are replicated
That seems like it would be too heavy
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.
I think the issue is that I don't really understand what the engine is doing then
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.
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
as long as they are marked as replicated, yes
awesome, thanks
In multiplayer, when to use the level blueprint?
Never
you replied to me?
Yeah
wow.............suprising..that's why I have been in big trouble
Do you know if the Level Sequencer blue print is also never used like level blue print in multi?
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.
Is there a way, in Rider, to debug the client code?
Breakpoint an IsNetMode == NM_Client that succeeds 😛
That is garbage lol
In multiplayer, can more clients connect to a level than the player starts placed in level?
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
If I'm not mistaken, it doesn't effect how many players can connect to your server, it might just cause it to look ugly if all your player starts are busy (have a player within their range) by trying to spawn players in the same place
I'm guessing you're doing some kind of a setup on the BeginPlay of a PlayerController and setting the PlayerName on a not replicated variable, maybe?
Is this due to default collision handling thingy while spwaning?
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
I am doing it like this using RPC to set names
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
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
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
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
so I made this in player state
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
You still need to use an RPC to set the variable in server
Currently you're only setting it locally
That's why probably every player just sees their own name
Yes, Run On Server event
it has same result
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
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
i know i did what you said and it is not working I dont understand 😄
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
IsLocallyControlled should be better
AuthCheck would probably not a good idea on PlayerState since it'll be false for every other client as well
You can plug your pawn to there
but i need somehow cast to it first not?
omg... get player pawn...
unfortunately its same
Well two things
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
I put the 4 player start to the level but I don't have to do like this? just one player start is okay?
And second, you'll always be settings the same characters name on your notify function since you're using GetPlayerPawn(0). Try to use your owning pawn in here as well
The server wouldn't reject the connection request coming from client. But as Jambax stated it might cause them to have some faulty scenes/gameplay appearing. One idea to prevent this is handling the spawning of the Character yourself. There might be other better solutions that I don't know as well
mean like this ?
i cant get owning pawn its from HUD class it says
Yes this looks better
It should be called something like PawnPrivate for the PlayerState
so like this its still same I dont understand
are there any potential issues with replicating float values?
I mean the other option would involve launching standalone and attaching the debugger to the client instance ^^
Not that I'm aware of any
wizard?
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?
yes
Steam weekly maintenance about to ruin everyone's day 👀
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
alright thanks
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 😄
Hey there, does anyone know how can I retrieve the current session as a variable? (Blueprint Session result)
Client tells the server it wants to pick up the bomb -> server sends a multicast event with an actor output of who currently has the bomb -> clients will then use than attach the bomb to the client that picked it up
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
How would a dedicated server handle loading and unloading objects / actors across a world for players who come into range?
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
Yeah. The server just has everything loaded all the time.
i have almost it done but this is problem this cast is saying it fails but anyway it will call count down why?
Uggghhh - but that takes too long 😭
I just want nice things
There was some watch you could create to check who hit the breakpoint. But I can't find that anymore):
Sometimes you cannot have nice things in life
where is the function that destroys PlayerState when player left?
Isn't it logout in gamemode?
I mean the exact place that calls PS to be destroyed
those function inside them they call lots of other functions
overload over overload
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.
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
GameMode already does that for you. GameMode, not GameModeBase. You could have just altered the InactivePlayerStateLifeSpan property
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 ?
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.
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 :/
anyone know how I can cast from pawn which is on map like bomb to game mode of multiplayer to execute custom event for count down?
So I figured I will just call the generate event from the game mode and replicate
you can just wire that spawning into BeginPlay or PostInitializeComponents of that actor from the scene
there is no need to bother the game mode, unless you need it to push spawn parameters
I need the game mode to get the player controllers
did u solve this I have spawning which is functioning
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
Yeah but it only spawn from server, not for the client
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
Yeah the players see each others. What I am trying to spawn is just an actor
hmmm additional?
after game is in progress already ?
right?
and what is that actor?
it's a player or cube or something else
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
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.
So an already existing actor in a map ( before play ) won’t be replicated, except if it is spawned by the server ?
What?
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 ?
If the actor is set to replicate (bReplicates = true or the checkbox in the detail panel "Replicated"), it will replicate.
Yeah that’s why i don’t get why only the server sees it, and not the client
Send code.
This is exceptionally basic functionality of Unreal. If it was broken, pretty much every project in Unreal would be exhibiting it.
how u know it's happening for server only? u tried run instance as listen server?
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
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
this event is in game mode or in player character ?
it seems you calling it from character
this event is in an actor in the world
definitely calling it in my game mode
That's because you're doing it to the owning client - which is the server.
even when set to run on server or multicast, only server registers it
I am sure I am indeed 😛
Look - if you don't want to do things the right way, then you do you.
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
its not that I dont want to do in another way, I am just trying to understand why ^^
Ok I am trying it
but i am not getting why are you doing get actor of class here
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
I just thought it would work for some reason ^^
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?
No not really
then tell me please 😄 I will better understand
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
and what should new spawned actor do ?
just be there ?
do you want posses him or play with it?
nothing gets spawned yet, for now I just want to have that event firing for server and client
I will launch my unreal and will try to make it and send you code ok?
ok thank you, I am going to try what you said to me
try but my english explanation is not best haha
You can't multicast from the game mode as was already previously said. The game mode only exists on the server.
Ok I think I thought somehow that because the server was calling something replicated, it would then being passed on to clients
so If I make the call from the player controllers which exists on both server and client, it should work
just call run on owninng client then ? i think
not sure
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.
hmm I am just curious how can you show 😄
sure !
my old machine still loading ue
this is on my third person character
this is on my player controller
the event 'create' is set to multicast
yes
and now both client and server gets the same result, which is perfect
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
to be honest working with multiplayer few months and I still dont understand it kekw
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
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.
I see ! so In the same idea, no client can contact directly the game mode as well right ?
except through controllers ?
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.
Correct, but not necessarily only through the controller. But it's one of the more common ways.
You have to run a server RPC to do anything with the gamemode. But clients really shouldn't be worried about that.
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
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
yep its because project once when you do some bad multicast/ server call idk why it get stucked at startup
75%
😦
i had same pproblem before
i reverted changes and saved them
now its ok
ahhh weird
can do it from scratch
Editor doesnt rpc at startup
its at 79 and was 75 before, maybe compiling shaders ?
Most common cause is incorrect number of uses of ConstructorHelpers
Correct number bring zero
no now its with reverted changes
But when that happens it will no unfreeze
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
If you have s lot of textures, shaders, etc... you might need to increase the size of your derived data cache in baseengine.ini
can you show me ?
maybe thats problem
(Dobro došli) XD
Its a config file in your engine folder
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
cant find it in
Search maxsize=512
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
I know but believe me its causing it I will show you
...
can I run log somehow with startup?
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
How do I decide what is a good net update frequency for my game ?
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
That's what Ping and Replication is all about
Delays should never be used to fix this
That's what OnRep/RepNotify is for
because its node from begin play where I am casting to playerstate and setting player nickname to it
when to do it then or where
BeginPlay of what?
Generally BeginPlay is probably too early
in player state its allright? 😄
of player pawn
But that's not your PlayerState
That will set the Server's Name to all Players though
BeginPlay calls on all Instances of the PlayerState
So also on Server
I am setting name there and then using widget to show it
And since Replication is Server -> Client only, that PlayerNick is gonna be set by the Server
:D I just told you it's not fine
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
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
BeginPlay -> GetOwner -> IsValid -> CastToPlayerController -> IsLocalPlayerController -> GetGameInstance -> CastToYourGameInstance -> GetPlayerNickName -> ServerRPC(PlayerNickName) -> GetGameMode -> ChangeName(PlayerNickName)
what about this
That's one long call 😈
okay
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.
I can also just say "Learn C++ if you want to do Multiplayer", but then I'm the bad person again
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
I guess it is better to use OnRep_PlayerState ?
Yeah but that is not available in BPs
idk I am lost XDDD
Uff
Can I call this deja vu at this point?
Oh yes right
no why u summoned here
I know Cedric
trying my best
You and some other smart people here have helped them but all in vain
It's a headache at this point
idk I red compendium like 5 times but maybe I am just dumb
that its not working
every time..
Sorry @real ridge but this is the truth
its fine I know 😄
u not hurting me
I know i am ..... dumb
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
I just thought when my variable is set as replicated its already replicated for all players
multiplayer concept is a bit tough learning curve, but you will get instantly with Trail and error
without nothing
No, it just means it would replicate to Clients if the Server sets it
You are not. I'm not implying that. I'm just saying that you are not learning from the advice. It could be the language barrier idk..
just give it a bit time
Which you need the RPC for, cause if you set it locally it is not replicated...
sorry I can try to not use discord anymore if I am annoying here....
i am just trying
to not give up even I am lacking
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
Why would you be banned for this?
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.
ahhhh
Here it's just that the Client has to tell the Server about the GameInstance value
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
@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.
i will try
Have you used breakpoints before?
only in c++ part
when I coded sessions
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.
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?
Visual Scripting is pretty good at conveying the flow of execution imo.
okay
will try this way too
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.
yes
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.
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?
With a breakpoint?
yea
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?
and you see some print on breakpoint? some values I didnt notice
ah shit some things messed up my project and wont load
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.
is it also possible see to what is where called via debugging?
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.
BCS I didn't see those large yellow if server or client weird
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
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
Any idea why net pktlag isn't recognised ? am I missing smthing ?
Cmd: Net Pktlag = 100
Command not recognized: Net Pktlag = 100
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.
Search for network then you'll find it under the Level Editor - Play section
yeah i cheched that , I really wanted to do in a debug build
You can also set them in a .ini somewhere.
can';t I use commands ?
ok will double check that
Hey guys,
If I call a Server RPC whats the way to identifiy the client who called it?
Search for NetEmulation in console there's some there yea and even an on/off command
I don't think that is the best solution but I sometimes send the UserID or PlayerState with it
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.
The client that owns that actor is the client that called it. A client that doesn't own an actor can not call a RPC on it from their side.
Okay Thanks @pastel escarp & @twilit radish
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.
Legend, that is the one I am looking for, Thanks 🧠
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?
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)
Memory doesn't really mean a whole lot. Your issue could be anything from CPU use, to network overflow either from network equipment or the engine settings limiting what you're trying to send.
Could probably simply keep track of an incremental ID client side for all rockets fired for that client and then have the server replicate that along with the rocket, then you can hold a reference by id somewhere too and use that 🙂
You have at least 3 frames of reference in a multiplayer game with dedicated servers. You need to choose who's truth to go with. Typically it's the shooter's, with the server doing some sanity checks.
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.
That's why I was suggesting just go with the server authoritative. Don't have to deal with prediction + server has the last say who or what gets hit 😄
Sure, if you want ping lag between your actions and something happening on your screen
Oh wait nevermind, misread your message lol.
That's what I'm doing for my game but it's slow paced. Could never do a Counter-Strike like that
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!
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.
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.
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.
Can't you just set a timer for every X seconds and notify the client? 😄
well its comming back to the same than just checking player status every 2-5 seconds as long as bleeding is unable right ? ^^
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.
That gets into a generalized buff / effect system
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
I love the idea of an actor that ticks on its owner ^^
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
The cpu is running at like 20% and memory is at like 5%
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?
Yeah that can work pretty well. Not as lightweight
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
How could it be data into the status component ? Curious about that one as well ^^
Tick -> Process buff stack -> ??? -> Profit
or timer
Well ty ty I will look into those solutions and pick one
Check out kekdot on youtube. His videos about multiplayer were enough for me to build all my systems. Took a bit of just trying things out after to really get the rpc structures and replication stuff figured out, but now it’s super fun and fairly straight forward for the basic stuff.
Took me a few weeks to get there with just a few hours per week to prototype
I guess @naive dome is on here! Massive shoutout to the channel from me!
Thank you for the great videos 💜
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.
As an addition to this also really try out stuff your self regardless of what you're watching, you can watch how someone else does it a million times but doing it your self is a totally different story @strong pond 😄
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.
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
is there any information on reliable RPCs anywhere? specifically, whats the interval between retry-attempts, how long does it keep retrying for, etc?
Have you checked the compendium?
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
Official docs going that deep just don't exist for anything, period
At that point they just expect you to read the source.
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
Im pretty sure reliable events will attempt to call the event until it is acknowledged by the receiving client/server
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?
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
--- 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
thanks, theres definitely some interesting stuff in there
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.
can I ask is this right that I have up SERVER - SIMULATING even its multicast for clients?
Multicast is called on the server too
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?
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
Ok thank you for the answer. It's a function for setting up the inputs and is run in HandleChangeInitState from the IGameFrameworkInitStateInterface so it should run on the local client. I'll continue to investigate!
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?
Sounds gross. What are you trying to do?
I am setting names 🙂
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.
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
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.
looks like this :3
it was only way which was working
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
Have you tested if it works when you start with one client then press add client while the game is already running?
nope but I will after I will package game... 😄 Idk how to run 2 instances in editor but one later, but i think it will work because firstly I used that event SetPlayerName to call via Press button F and when I pressed F on one window with player names changed on both windows when I pressed F on second window same
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)
You don’t have to package to test late joiners
so then I added multicast and vuala
I told you
Start with one client then once you’re playing press the add client button
Near pause and stop
I am blind?
What net mode are you using?
Ohh that could be
play as client
Ok
play as listen server, then add clients as needed
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
yea thats what I do
I check if im playing in the editor and if true, generate random name
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
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.
i dont get your advice
can you better explain
I can try comment and try it with your idea 😄
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.
i understand where I can check how much is network used ? and if I need something change
do you know what I mean
hmmm
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.
ahh okay some free profiler ye?
yea thanks
This week we'll be joined by Ryan Gerleve and Dave Ratti to discuss general server optimization in UE4, as well as techniques and solutions to improve your Actors' performance in a networked environment.
NEWS
Unlocking Breach’s combat with Unreal Engine
https://www.unrealengine.com/en-US/tech-blog/unlocking-breach-s-combat-with-unreal-engine
...
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.
btw tried this what u said and result was that every time new player joined game all names changed to another numbers so every join when player joined player got new name which dont need be bad at all as I am just generating it and it propably executed again so if there was just 1 static value as Nick it should be fine
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?
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
i know as I understand good remote -- means it allow call only on client and remote it allow call only on server
Run on server is only used when you know for sure it’s running on the client but needs to happen on the sever.
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
✅
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
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?
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.
Yes but only if the incoming process is already happening on both which you can test by setting a breakpoint
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.
so basically on event tick or begin play
sure
Pretty much all actor events are trying to run on both yes but it’s up to you to make sure cheaters can’t cheat by checking gameplay logic such as when a plane shoots another one on the sever.
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 😄
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
yes thats why I used those so its fine aight?
when I check its 0 I just destroy actor
That’s an unnecessary rpc
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.
YOU GOT THIS!
I’m looking forward to trying your game one day.
Is there any way to set the world origin rotation?
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
Yeah that's what I was trying to explain but I got it wrong
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?
How do I get the latency from a client to the server ?
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
What is your error on joining, can you host? Maybe you forgot to cook something?
]LogOnlineSession: Warning: STEAM: Invalid session info on search result
another thing when i click join it keeps on sending me back to main menu after join session why?
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
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?
I can't recall it being possible to mark interface functions as rpcs.
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
You only need ReplicatedUsing
So I'm guessing it wouldn't be safe for my "ReceiveDamage" event
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
LOL my bad
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?
You usually RPC before or after the interface call
Interfaces themselves are just normal functions
Not sure what you mean with safe
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?
Why
Because couldn't someone call that function?
That's always the case
No matter if interface or not
Again interfaces just provide normal non-networked functions
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
You should never have an RPC to deal damage in the first place.
How should you deal damage then?
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
fast question can I cast to game mode from player controller? or call server from there or its fully client side?
Including the resulting damage
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
You can only access the GameMode on the Server. PlayerController or not doesn't matter
eXi - were you the one that told me that you typically use in-place animations but apply root motion sources for your games?
I tried that recently @real ridge and I had to replicate the data to the game state instead
Could be
Yeah cause the GameMode doesn't exist on clients
okay
Multicast makes no sense in a GameMode
player state will solve it
GameState probably better then
u saying it to me? i am not doing rpc in game mode
So okay, where would I have the function that removes hp from the actor then. Like which class should that function exist on?
I have been trying to do that, and it works well, except for one small (yet big) caveat
Why does that need an rpc
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
Honestly idk, I thought that anything I wanted to replicate correctly had to be run on the server
No
I didn't want a client running that function, so I set it to run on server
it (mostly) statically applies single motion and never adjusts
Above is playing real root motion w/o root motion source
You only use RPCs if you want to move from server to client, client to server or server to all
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
player state working perfectly!
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?
the second one, if I turn, then I move backwards
like I am moon walking
I am not sure how to deal with it
You don't need to use root Motion Source here fwiw
The rootmotion of that anim as a montage is just fine
@wheat portali does the animation blueprint run on the server or client or both?
Still wrong though given you multicast in the gamemode
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
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
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
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
already deleted it
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
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
doing it I just wanted send
that player reference who overlaped
to game mode
and there check if he had ?bomb boolean true
I can't really say I faced that issue. The Singleplayer Project def had a RMS that applied rotation too. And the Multiplayer project is top down. We don't rotate while performing the ability
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
oh ok
try it via function?
@real ridge https://vorixo.github.io/devtricks/stateful-events-multiplayer/ this should help make things more clear
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