#multiplayer
1 messages · Page 165 of 1
Sorry, i made the assumption you are using FInstancedStruct
You definitely want to call NetSerialize on the elements.
Just a sanity check, 'listen server' PIE testing is what I want to prototype with for hosted (non dedicated) multiplayer with steam sessions yeah?
SafeNetSerializeTArray_WithNetSerialize<31>(Ar, ReplicatedSockets, Map);
Take a look at that function. Its in the NetSerialization header
The first player is going to be authority and will be the server, all subsequent players will be clients
Play as client will make all players clients
hello, I have a trigger box on the map. On overlap, I would like to execute something on client only (or host only if server). I could run on server and execute client rpc. But is there a better way for this? Only relevent to owner maybe?
dang i wish the CMC didn't handle control rotation.. the only issue with setting its tick rate low
but i guess it makes sense since control rotation is related directly to the direction you're moving
Hi I was watching some old videos on optimization by UE and came across this Network Relevancy View Mode. Has this been deprecated?
Hello everyone, I am attaching my character to a scene component in the car actor. Server drives the car and Client attaches to the side seat. As the car moves forward, the Client slides into the seat slightly backwards. How can I solve this?
if its an overlap with a pawn slap an IsLocallyControlled
Anyone any clue as to why this would return a not valid on the server, but is absolutely fine on the connected clients?
This is inside a character BP, and the character gets spawned by the player controller.
maybe use "get player controller " instead of get controller , see how it goes
Because by the time begin play runs, the pawn doesn't have a valid controller
Use OnPossess or something like that in the pawn
Yea I tried on possess but that doesn't work. On controller changed seems to get me a step closer though
OnPossess only runs on the server
Right, so then it wouldn't work for any of the clients right?
Unless I create a custom event that is fired through it and replicated to the owning client
There is one that runs on client as well, don't remember the name though
Yea I think it is the on controller changed one tbh
I now have control of the player on the client and the server side, so the setting of enhanced input was successful, meaning the ref was valid, yet the print string on the isvalid still activates on the not valid
Away from my pc though at the moment, will explain in more detail later
Also, what is the specific reason behind this? Is it a matter of the initialization happening later?
Because BeginPlay can be called before the possession of a pawn actually happens
Right I see, that is good to know for in the future
Very common thing that happens to some people in #gameplay-ai
Why the input of the joined player isn't disabled for the client but does for the host even if I call the "Disable" Input method ?
Hey, do I still need to encode/serialize a TArray<FHitResult> I want to push from client to server or would this datatype benefit from FHitResult serialization and only submit deltas by default?
is it necessary to mark a timeline as replicated on a multicast event_
Is it necessary to multicast a replicated timeline
shouldnt be, as in both cases the timeline should be starter from the server
I wonder anyone tried modding for multiplayer stuff ? Like custom environments created by player and join with their friends. Like making that level accessible for their friends by sending pak files or so.
Will it work ? Is it possible ? Or my dumb ideas overkilling me ? 🥺
the repnotify function only runs on set or as soon that variable is touched_
Can anyone explain to me better how replication works? There is nothing wrong with the anim instance part, in my BP_ThirdPersonCharacter there is a bool variable called bWalkInPlace that, through a flip flop and the B button pressed, i alternate the value between true and false. And in my anim instance this boolean is controlling the animation that my character should perform, this part is working, but I don't understand why when I press this button on a client, nothing happens. Is my line of reasoning wrong? In my head I understood it this way: I press the B key, and only on the server is the WalkInPlace variable toggled, and as it is marked as Replicated:true, and replication occurs only from the server to the clients, the server sends back to the clients the value of this variable, which in turn will be consumed in the Anim instance and thus change the animation. When I do this on a server-side it works normally, but not the other way around. Could someone explain better how this works for me?
Does anyone know why UE spawns 3 player controllers when I try to test a listen server setup for 2 players (1 server, 1 client) in the editor?
Assuming this is a listen server, it doesn't. It's 2 controllers, one of which is replicated.
One of them is for the server, as for the others...
When a client joins the server, the server spawns a APlayerController for the client and stores it locally so the two have a channel they can communicate to each other. Afterwards, client spawns its own PlayerController locally.
Aha
interesting
Is it normal for your brain to melt when you are trying to learn replication?
Yes
Great, then I am doing one thing right at minimum
This is not true. There will be 3 APlayerControllers spawned. Period.
It absolutely is true. That one is hooked up on the client directly rather than replicated normally is an implementation detail and nitpicking at best.
Conceptually those 3 instances are just 2 controllers with one replicated to a client.
3 instances nonetheless. They pretty much share the exact same lifecycle.
Yes, but you're nitpicking what I said. It's not wrong, it's a different way of saying the same thing.
And it's important to be able to think in terms of both depending on what you're doing.
Fair enough.
So then how does it work in the following context;
Upon the character getting possessed by the controller, I want to spawn another actor for each player (2 players). As far as I understand it we always want the server to spawn things to avoid players cheating in any kind of way. So that would mean I would only allow the server to spawn these actors, however, when I do that it does it 3 times, which might be correct, but is not what I was expecting.
How would I approach this? It has become clear to me that the udemy course I am following, albeit a high quality one, explains the concepts of replication in a very narrow context that does not allow me to learn how this works in my own contexts.
BeginPlay of Character you do a HasAuthority() and, if true, Spawn your Actor passing Self as the owner of it and mark such Actor to bReplicates = true (you do this in the Actor's Class Defaults, found in the top bar of your Unreal)
Also, spawning actors on the server isn't exactly only because of cheating per say. The reason why you want to spawn actors in the server is because otherwise how would the other connections get to know about its existance? The server is the man-in-the-middle of all clients and their interactions.
Or rather, you could Spawn such actor on the Possessed event, which only runs in the server.
Okay check. Actor is set to replicate, and in the following screenshot you can see the execution line coming from On Received Controller Change. I then check if I have authority, and if not, I will go through the motions to spawn the actor through the server (by using the gamemode).
The result is that 3 golf balls spawn in my level.
What is this doing
which replicated to the client as well. I seem to be unable to control the player
Just calculating the spawn transform and then create actor from class
Also it's unlikely you need this On Received Controller Change - just use the ACharacter's Possessed (or would it be APlayerController's? don't remember from the top of my head)
Possessed -> Spawn
All you need, no requests and other 99999 functions in the middle & whatnot
Right gotcha. so I made those changes, now I have 4 golf balls on the server, and 3 on the client 🫠
Gotcha, here is the possess event in the player controller:
Beginplay in player controller
Server event for spawning the player character, running through the gamemode (for verification? according to the course).
Make this a Server RPC and don't go to the GameMode
Just replace this Server SVR Request Spawn Player by your SpawnPlayer
What verification?
That is a great question that I do not have a meaningful answer to
Okay this is progress. I am now actually reducing other errors that I was facing before, however, I am still seeing 4 golf balls but now on both client and server
So
Just spawn your actor right after spawning the Character, why not? ¯_(ツ)_/¯
If you have 2 Characters, you'd have 2 of this other Actor of yours - don't need to complicate
But should I then do that in my player controller, or can I do this inside of the player character
You can do it in the PlayerController, exactly after you spawn the Character
Testing now
Unless your golf ball has some sort of dependency of the Character that happens after it spawns or gets possessed by the client
Okay, now I have 3 golf balls on both server and client
3 on the client? Are you sure it's not 2?
triple checking
Server side pic 1:
Client side pic 2:
So yea definitely 3 on both sides
And how many Characters do you have? 3? 🤔
A print string on possessed indicates 4 messages from the server saying CharacterSpawned
BeginPlay of ACharacter prints how many times?
So the Possessed is firing 4 times. There are also 4 custom player starts in the level, but that shouldn't matter if I set the play in editor settings to 2 players
There's something weird going on right there
Yea that probably does not matter
Beginplay prints 3 times from the server, and 3 times from the client
The order of those prints is the same every single time too, so after those 2 players have done their thing, it seems like a third player is added/initialized later
... which explains why you have three golf balls. Your problem is addressed, what's left is a mystery unrelated to the current matter.
Yea, and I just checked in the course project, adding a print string to the beginplay of the spawning of the character. there I see 4 print strings. Once from server and client for each spawned player
So that is definitely correct, question is why the exact same setup is behaving differently here
Alright, here comes the flow on the course project;
- Comes from the widget blueprint on a button press.
- Goes to Gamemode on the server.
- Goes back to player controller with the spawn transform information.
- Comes from gamemode, spawns player, possesses it, and then does some client side setting of input mode.
Well only if I use a widget to control the spawning right? Which is not what I want to do necessarily
Then you stop requesting spawn from the widget hehe
Because Widget is asking to spawn, but you also request upon spawning the PlayerController
haha, yea doing that stops any player from being spawned at all haha
Oh right, no in my project I am not using the widget at all to spawn the player
spawning happens exclusively through the player controller
Hm, aight - like, it seems you have 4 characters for 2 players; there is something weird going on right there, and if you're not using the Widget et al, then I don't know? 🤔
It smells like you have an ambiguity somewhere
Yea that is fair, it is very strange
Yea my main mistake so far, has been to try and convert a previously singleplayer project, into a multiplayer one 🫠
Make sure there's a single place calling this
Yea there is only one place calling that event
Wait
Are you auto possessing your Character?
I mean, GameMode defaults -> make sure it has no default Pawn assigned?
Yea default pawn class is set to none
thats the name of the game it seems
Really appreciate all of your help and assistance @gloomy tiger
I will report back once I find the true issue
Cool beans
Just a heads up - this call below does not guarantee the Player has received/possessed their Character. In C++ we have AcknowledgePossession (https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/GameFramework/APlayerController/AcknowledgePossession/), not sure how it'd work in Blueprints tho. That to say - if you do things that require the posssessed Character inside this function, expect it to be quite unreliable since there's no guarantee the entire possession pipeline has happened end-to-end.
hey there!
I took the third person template and attached EOS login to it.
when I become a p2p host on my beefy pc, everything works fine. but when weak laptop hosts, i get massive network stuttering on client.
how is this usually solved? is it maybe possible to pass the host to player with best pc before match starts?
Yes, it is possible to pass the host to the player with the best PC indeed, but that's a complex process and AFAIK, the Engine doesn't offer anything out of the box. I know there's a plugin in the marketplace that solves just that, but anyways, that's pretty much it.
Apart from that, I believe these are the two options you got:
- Optimize your game - mostly the CPU usage of it - as much as you can and/or,
- Take it for granted and put a disclaimer in your page saying 'to host the game you need a beefy pc'
I remember I've seen a game on Steam that had two minimum requirements - one for the host machine, and one for the client machine. Can't remember the game though.
But that's how it works - no matter how optimized your game is, the host will always be more resource intensive (in p2p scenarios). If your game is pretty well optimized already, then a disclaimer is all you have left - or you go to the 'transfer host' approach, which is complex and unless it's a serious serious (twice the word) project, I wouldn't bother. (Also, transferring the host doesn't solve the problem, it only has a chance to mitigate it. What if all computers you have available are as potato as the notebook you mentioned? lol)
I see. There is plugin but it is not yet updated to version 5.3
My original idea was to not allow players to select host/join but rather host if there is no free matches. I guess dedicated server would've solved this problem, but I cannot find any info on how many matches can average server host...
by average I mean, idk, like 12/24 ryzen pc
I guess dedicated server would've solved this problem, but I cannot find any info on how many matches can average server host...
There are lots and lots and lots of factors here. It all depends on how you optimize the game. Dedicated Servers would definitely improve the experience of players in general, but as always, lots of trade offs as well - fleeting, extra costs, matchmaking, backends, etc.
Hi there, im trying to do a hanging bridge with physics, where each plank is tied together with the next one using a physics constraint. This is bad for replication i realize, but if I were to simulate on a server and just set everything when location/rotation changes, shouldn't it be possible to get something ok stable on a client?
So far i've managed to get the movement to look smooth by sending over loc/rot on tick (just for a test), it looks correct and all, but once i step out on the bridge as client, I get booted from it (ejected rather). Any suggestions what could be the cause of that?
shouldn't it be possible to get something ok stable on a client?
Probably possible. Not exactly easy. I think you're on the right track, though: simulate on the server, replicate the end result. But getting clients and servers seeing the exact same thing every frame goes beyond me. Not saying that's what you asked for; just imagining what would be your end goal. Regardless - never dove deep into physics + replication myself, so probably somebody else can help you out better.
@gloomy tiger anyways thanks for ideas. I am yet to learn how to optimize for cpu and networking, considering its just third person template without anything else going on. I will do my research into it~
If you're into a more serious project, I'd highly advice you to go the C++ route. Not sure you're doing that already, but Blueprints isn't feasible at all, unless you're doing something like a turn-based game (and there are nuances even so)
i'll experiment some more with it and see if i can get something acceptable
Good luck!
I try to only use blueprints for visuals and guis
I think it is intended workflow, someone on youtube said its best to mix
If you send an RPC with an actor pointer that's to an actor that might not be spawned yet on the client as it was spawned the same frame
Would it delay the RPC read until the actor is spawned? or just receive a nullptr?
if you execute it on the server and somehow got a reference to it, it must exist there
I mean an RPC from the server to clients
that has an actor pointer that will be spawned from actor replication
good question
My assumption is you can't assume one happens before the other and have to have a simple ID sent in the RPC and sent on the actor's initial data
if you immediately need to send something, probably validate it beforehand on the player side and if null, delay it for a second
and have the second of the two indicate both are present
is there any idea of a "net ID" you can send in pre-iris?
I'm trying to help a friend with this problem fwiw, I might just direct them here
Most everything is given a Net GUID after the first time its sent across the network
so could they send the FNetGUID in the RPC
and if the actor is second, it completes the "both are here ,do stuff"
and if the RPC is second it finds the actor and does the "both are here, do stuff"
that's my dumb assumption of how to solve this problem
assuming the actor being replicated is easier than just having it spawn FROM the rpc
You want the client to hold onto the NetGUID and check every Actor that gets created to see if it has that NetGUID, to then process whatever the RPC was going to do if it existed?
no, only the one specific actor needs to override PostNetInit
It's kind of like, a player pushes a button which spawns an actor on the server
But you would have to cache the NetGUID somewhere for lookup by that Actor
seems simple enough
Sure, im just trying to understand what your trying to attempt
I mean, I guess it might work?
I guess the issue is they want the button press to be an rpc
and to spawn the actor from replication
and have the RPC know about the actor that's replicated
feels to me like the actor could just postnetinit and callback to that
with no rpc needed beyond the one to the server indicating the button was pressed
gotta go for a bit, thanks for the help
RPCs are only one way though. If you want to know the actor that was spawned, you could use an onrep "Actor" property on the player controller that initiated the button press or on some other replicated actor that other players can read that info from. When that OnRep triggers, you can check if it is valid, and if valid, then you know the actor that spawned on the client.
"or on some other replicated actor " would be just as complicated though, no? does the onrep gaurantee it will eventually send a true actor pointer that the client has?
An example would be, say you have an actor that is a "spawner" of some kind that you're interacting with that actually handles the spawning. If you wanted all players to know what the enemy is that it spawned, you could have that "spawner" actor set that OnRep reference on itself. When that OnRep triggers on a client, you check if it is valid or not - if it is valid, then it must exist on the client for it to be valid. This would then allow _all_clients to know that the particular "spawner" spawned that instance of the actor by reading that property of the spawner.
If you wanted it to be player specific, like only the player that triggered the spawning to know about it, then you'd use something like the Player Controller or their Character to hold that reference. If you did it on the player controller, then only the owning client would receive it. If you did it on the character, then anyone could potentially read that property (depending on the replication conditions) to know what thing it was they spawned.
whats the difference between net dormancy awake vs never?
Hey everyone, I'm seeking some advice. I'm in the initial stages (design phase) of a multiplayer shooter project (TPS). I'm wondering whether it's preferable to stick with the current Character Movement Component (CMC) or to invest time in learning and implementing the new mover. It's worth noting that this project is intended for long-term development. Thanks!
You should break down what your motivations would be to use Mover 2.0 over the CMC.
Mover 2.0 will likely stay experimental for a few releases and is unlikely to be stable and without bugs.
The CMC is very stable and reliable.
These should factor into your choice.
If your primary motivation is that Mover 2.0 is "newer", I would heavily reconsider what your plan is.
"Newer" does not necessarily mean better.
Hi,
I'm using IOnlineSessionPtr::FindSessions on PC but the TimeoutInSeconds I set (1s) is ignored and I get the default (5s). Known issue?
using FOnlineSessionNull
Perhaps I would have to compile the source and set LAN_QUERY_TIMEOUT
/** Amount of time to wait for the search results. May not apply to all platforms. */
float TimeoutInSeconds;
or any platforms...?
Does any one have a moment I am still struggling with this button problem - i am so close with Adriel's help but stuck at what appears to be the finish line
I keep trying to map player input to call a server bool to update but nothing happens - i am getting a warning about ownership but not sure where I am missing this
Error reported:
LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_Button_C_UAID_D45D64D6AFE8D9E401_2043887119. Function OnButtonChangedState will not be processed.
This error message indicates there is no owning client connection but you're attempting to call one through that "Run On Ownign Client" RPC.
I have tried to set client as owner of the bp_button on box collider over lap to no avail
Adriel mentioned i need to map the player input now into the button but that high level of instruction just doesnt seem to get through my dense noodle here
All my RPC's set to run on server i thought was the right way for this type behavior from client to server
For ownership read the compendium pinned on this channel
U can't call rpc on actor you don't own
Like i said i tried to set owner ship of the actor to client on overlap w the box collider for the button logic
So for client, it's normally the controller and pawn. And some things that is set to the player via set owner
I just seem to not be getting any where
It's a pretty bad way to do it anyway imo
U don't normally want to set ownership for things that doesn't really belong to the player
Like a box that can collide for example in the world
Aside from bad design, it's easier to hack the game
Well
I have a button
That is functioanl on client
but server does not get any bool update
Is the game mode the only thing that exists on the server?
The only way for client to communicate with server is thru server rpc
That's the biggest tip that u need
Its just a tutorial super noob question here , very much appreciating the knowledge
I have done that Cold
I dunnoe
thats kind why im stuck again 🥲
Don't have your project
I see that you set the bool on input, in client machine, that will only update the bool locally
Souldnt the RepNotify update it server side?
It's common to get stuck in multiplayer, the usual advice is to read the comedium at least 6 times
Replication is only one way Server > Clients
Then another 6 times if u are still stuck
RPCs is how clients need to communicate to the server.
SO what is the ppoint of run on server rpc?
To run something on server?
That's to ask the server to do something.
So why isnt my rpc working 🥲 lol
Replication is not the same thing as an RPC.
Read the compendium again >_>
I promise i will never ask another question here before reading the compendium 10x
but i really just wish i knew why my button doesnt replicate and my rpc doesnt work at all as planned
Lol pls
Go simpler to learn, stop what u are doing. Try to sync a bool with client and server using input
Don't need time line , collisions etc
Get the basic down first
Currently you have an input, which is typically local only.
So if you're pressing that input on the client, you're then attempting to set the state of a variable on that client which won't replicate to anyone else, and then trying to send a run on owning client RPC which this actor doesn't appear to have an owner.
If you're pressing that input on the server, you're then attempting to set the state of a variable on the server, which should replicate to everyone else, and then trying to send a run on owning client RPC which again, this actor doesn't appear to have an owner, so you get the error.
I did go simpler w adriel yesterday w used a vector first with remote auth
errr not remote
Just change a bool on key press
Make sure it's sync Wether server do it or client do it
If u can't get that working yet, u won't get w.e u doing to work
I dont see that datura isnt the RepNotify and Custom event set to happen server side
Normal flow is:
Input from Client > Run On Server Event ( on an actor owned by that client) > Server does things with that Input, such as setting replicated variables and calling any additional client/multicast RPCs.
Thats why im so confused why that hack didnt work earlier when i set owner of the button to client shouldnt it have been enough to update teh server bool?
If you're attempting to run on server on an actor taht isn't client owned, you'll run into a similar problem as the one above where it ignores the RPC as the client isn't the owner of that actor.
Man so frustrating everytime i feel like I am close but not quite seeing the light yet 🥲
Hi Matt, thanks for your help. Basically, I have two reasons for being afraid: first, the potential deprecation of CMC during my project development, and second, the promised ease of Mover 2.0.
Ive got other simple things like a box pick up and displayed value working fine with repnotify but this bool..
CMC will not disappear, it will just simply stop being updated.
it haunts me
there's a new cmc?
@west cairn keep reading, replication and server rpc isn't even the hard part for multiplayer.
Mover 2.0 in UE5.4
aaa ic
I was stuck too, but once you get it, not hard
what does it come with?
Is designed to replace it
i c, but what if found a bug, it means I will need to fix it alone
Go and read up on it?
I just wish adriel had mentioned what he meant yesterday during our discussion i just cant make sense of the high level advice we left off on
Its to much to explain here TBH
He really helped me get things moving
np, getting familiar with mover 2.0 in preview
aaa mb
Replication in general is quite nice the way UE handles it, ive just been stuck on this problem for a while so its one of those phone a friend type moments
but i have no friends that do UE MP dev work
Mover 2.0 will likely be unstable and unreliable for a few releases.
Take this example - this is done on my PlayerController. Try doing it on your player controller and it should work just fine when you press the P key.
Yes see!! thats exactly what i think adriel meant
mapping player input to this interaction
that custom event i wrote in on bp_button though i cant access thorugh the bp_thirdperson char howevver
And that's why right now, you should stop even trying multiplayer anything if you don't know how to reference things.
I need to extend to the character with this now imo also Dat i think youve got it i will try to see what i can do
well why not just explain the solution instead ?
I already have.
I'm not trying to discourage you, more direct you away from something that is far more confusing
Dude i said i am a noob so many times
there is no need to remind me of that fact
🙂
What is this referencing for the sake of completeness?
Can I migrate the host status between players? Like instead of terminating the session when host leaves we make someone else server. Is this possibke?
I will go away with my button problem i promise lol
is not that, its more baby steps 😄
No
to get a strong foundation
Not with Unreal's built in networking engine.
I began working with unreal Jan 24th. Thanks for the help guys! I will try and see if i can get this to work 🙂
You get reference to things that exist in your game. Your player controller exists as a "thing" in your game. As does your button.
No. A cast is a type-check.
Totally shouldn't be doing multiplayer yet. You are trying to sprint before you can walk
For persisting the game I need dedicated servers there's no other way?
listen im just trying to learn the utter basics of MP with a simple button press
in no way shape or form would i try to make mp game on my own
i can promise you of this
but to reference with a blueprint what exactly was meant? Am i missing a nodeI should be thinking of when trying to do this? lol sorry for being new i guess
And you shouldn't be trying to learn the basics of multiplayer if you don't know the basics of Unreal/Object Oriented Programming.
There are many tools that you can use to get a reference, like overlaps, traces, etc.
Very thankful anyways! appreciate all the help and input 🙂 best on your guys own stuff !! u got this
What that tool provides may only be an "Actor" reference in which case you may need to cast, or you'd use an interface or some way of communicating to that reference.
Watch blueprint communication by Matthew if you need some guidance on references
It's too long for anyone to cover
I think people should always be encouraged to discuss and learn no matter what level - But i do appreciate your advice to try more single player local or even learning more basics of OOP is great fundamentals
Thanks cold ! matt's videos go HARD they are amazing
Best MP rep video out
It is foundational to multiplayer... Multiplayer just makes it worse as now you're not only having to think of what exists on the local computer - it can exist on multiple computers @_@
UE needs to hire this man
And it may exist on some, but not others @_@
Well ive been at it a week
It's an advice I would give to my self, I'm trying to help , as discouraging it may sound
so far its not bad but when i am making my own stuff up off the path - all goes wrong haha
He worked at epic
Got laid off during the mass firing afaik but he did get hired at some point
Yeah the only way id think of is an interface for this blueprint interaction so thanks for the advice all !
aww 🙂 well i will watch like and sub to his unreal videos regardless ty for the lore hah
If it's something that collide with player
Just do the logic and check on server machine
Especially a box collision
I can follow your instruction until the point of implrementation ')
I will try to stare at Dat's BP's and matts video , read some docs ty all
I really appreciate it have some fun guys its sunday nite!!
if i wanted to start digging into multiplayer programming with UE5, what would be a good target to hit, like a pong game or something basic?
A simple "pressure plate" kind of button where the player just needs to move on top of the button is fairly simple in multiplayer, as you can have it all done on the button actor itself.
- Detect a collision > Gate with "Has Authority" so that it only triggers on the "Authority
- Do whatever is required such as setting any bools and calling any multicasts.
A client needing to press an input to then trigger something on a separate actor needs you to be able to do several things:
- Detect if there is something to interact with when they press an input of some kind, this requires doing some traces, overlaps, or other means of selecting the actor you're wanting to interact with.
- Send an RPC to the server (through a client owned actor or component of a client owned actor) asking to interact with a reference to that specific actor (the RPC should have an "Actor" type input that you feed in the actor value to).
- The server can then use the actor reference and call an interface that is implemented on the actor or call to an "interaction" component on the actor.
- The actor component or the interface could then do what is required, such as setting any bools, and calling any multicasts.
Running on Owning Client can be done, but it usually requires passing along a reference of some kind back to the player that is performing the interaction and it doesn't necessarily need to be if you're able to control things with replicated stately things like bools, integers or enumerators that you can set with OnReps that can cause things to happen on the client without needing to call a Client RPC.
Marco Secchi - Multiplayer Game Development with Unreal Engine 5
This is the book i am beginning with. So far Ive got a dedicated server, replication and simple box pick ups with replicated UI widgets over the players dialed (lol chaper 3.) you may enjoy the book.
Its super hand holdey and will absolutely get your feet moving. I dont reccomend trying stuff on your own otherwise you'll end up cursed like me trying to replicate a button press for way longer than you'll care to admit 🙂
Widgets don't replicate
Technically a text render yes correct 🙂
But you'll get your feet moving with out these guys telling you not to do MP stuff early on. I figure why not go crazy and try what ever you want 🙂
i mean based on what i've done while dipping my toes in... wouldn't you just use an RPC call if you needed to tell the server that a client pressed the button
The issue is ownership as datura said above
My button is serevr owned
I tried a hack to make it client owned but as cold said its a bad praccy
what is even the button
best to avoid and do it right
some pressure pad in the world?
oh i didn't read that entire thing above lol
i figured he meant a regular on-screen button like in a UI
the button if you looked at the BP is a SM_Chamf_cube from the starter content , that is scaled to like .125 uniformly, then moves in some dimension like 10 UE units - i say just have fun!!
go for it !
and how do you activate the button? oN overlap? so it's like a pressure pad right?
that book will get your feet movin! these guys are super helpful u got this
how much is this book?
uuhhh..
lmao
i haven't had much trouble just digging through the UE docs so far for what i've managed to accomplish
reading the compedium is enough for replication, RPCS and ownership
@cunning pond the only docs you need is the compedium pinned in this channel
Well give it a look if want a jump start project beyond compiling lyra=) !! u got this man
https://www.amazon.com/Multiplayer-Game-Development-Unreal-Engine/dp/1803232870
$36 🙂 make something beautiful friends
Not sure why anyone would pay anything for a book on developing with Unreal, all the information you need is online for free.
rofl never thought id say these words but ily datura. def helped get met SORTED man
Its a super great start for noobz needing a push! he asked for the price idk its surely not $110 thats all i know
Its just info sharing im not bashing the docs at all they are great. This is just an add on or dlc 🙂
didn't notice I get routed to Australian website
still expensive tho
not attacking anyone btw
it's good to push your self
I mean $36 is indeed pricy. that rounds up to 1 copy of Helldivers2 man!
we are trying to be helpful by saying you should climb step by step
Which is a barrel o fun 🙂 i hope u guys are working on killer MP experiences too
not knowing OOP or references and jumping to Multiplayer is not gonna work imho
hence the only advice that can be given is to start from OOP first
this is what i was kind of thinking but i wasn't sure if i was just wrong lol
Buying a book on technology like UE5 is silly. A lot of information in it will be outdated in 12 months.
Datura and Adriel forsure got me a lot of help and the lot of ye i appreciate vastly. id just say read and make as much as u can - have fun with it. great group of ppl to create around
dont be afraid to ask dumb stuff some one will maybe say something that kicks ur butt into gear
reading is good, I love your enthusiasm, I am learning my self too and a pleb in multiplayer but for what you are doing, all the info are laid down in compedium
so without making assumptions of what material i'm using to learn, what is a good starting project; for me i feel like i learn best by just trying certain things out once i have a handle on the basics
for free and compacted to a number of pages
Anything that involves ping will be much much harder
you probably want to start with turn based game
Board game, chess, etc
ok
There are more features you do have to cover if you are doing FPS or TPS
client prediction, server rewinding are one of them
Honestly, try opening and closing a Door in Multiplayer with a UI element for initiating the interaction.
You will have enough trouble with that as a beginner.
like opening a door and making sure that other players in the game see it open?
Yes, all Clients and the Host must be able to open/close the door.
Agreed Cold!
Kekedot was a pretty inspiring poster on youtube also that got me wanting to tinker with mp. lol they all make it look so simple ! then you get infront of your own implementation 🥲
Adriel here said something along these lines that you want to approximate your game state from the server to all clients in as efficient of a method as possible. whether this involves net cull , or special rules is up to the experienced net coder.
I suppose as noobz the best we can do is read like mad, tutorial until blind and stay positive.
This sounds painfull
wooow big hugs and thanks to all who helped me make the little functionality I wanted to tonight. I couldnt have done it with out all the super help (Adriel yesterday too! superb all of you rly i mean it).
I wanted to do everything on bp_button at first also!! But ended up going with interface.
And also Matt is 100% on point saying UE books tend to go out of date about as fast as well any textbooks i guess 🥲 (im lookin at you calculus 12th edition!! smirking at me with money eyes)
hey guys, I want to have a system that keeps count of enemies that are spawned in an area and calculate the distance between them and players so that I can spawn additional one based on how many there are close to any player. So far I was spawning doing the calculation in the GameMode, because it's server side, but perhaps there's a better way to handle this, than the actual game mode? I heard that Subsystems might be good for that, but not sure how exactly to use them with the rest of the systems available. How would you do such a thing?
Spawner manager i guess
Youd probably want a spawning subsystem to keep a clamp on max enemies etc
Yeah I would just create an AInfo as a manager for that task. The GM spawns the AInfo.
what type of Subsystem would that be? There seems to be a lot of choices
@gloomy tiger It has been resolved 🙏
I am still in the dark about what caused the issue in the first place, however, upon checking the Event OnPostLogin event in the gamemode, seeing it was only ever registering 2 controllers logging in, I figured I could hook the player spawning up to this logic. And this made it work.
Now only 2 golf balls spawn, on both client and server, and I can control them both too 🙂
thank you, if I have trouble, I will ask here
Just out of curiosity, what is a good way to think of a subsystem? I’m having a hard time thinking of why you’d use one vs something else. What makes it unique or makes it valuable to choose over something else that could do the same logic?
The only real advantage is they have a strict lifetime which usually makes them easy to access. Otherwise, nothing.
Ahh interesting
Am example is that a UWorldSubsystem has a lifetime that supercedes actors, so they are always easily accessible to any actor at anytime
Yea I could see how that could be useful. When making your own do they work like typical bp coding?
Subsystems are nearly always C++ only
Lmao wel then. Subsystems are not for this guy!!
@crisp shard I like the encapsulation, instead stuffing my Game Instance, I can have a subsystem instead for the loading screen
You’re using a subsystem for ur loading screens? Seems excessive to how I’m understanding their usecase but I could be missing the simplicity cause I don’t code cpp
It has to be CPP and I have to use game instance to keep the widget alive
not possible in bp
all widgets get destroyed during hard travel without interference
hello,
on server side i am calling a interface on a replicated actor, this interfaces call another one with a param (1)
the thing is, the param went back to default on the interface fire (2)
any ideas ?
Makes complete sense. Interesting topic tho
the uses are straight forward, take EditorSubsystem for example
you can have your custom actions for Editor there without overriding the Engine class
I'm sure its a trivial question, but how do you predict stun effects on client?
To prevent correction rubber bending when client01 stuns client02
Since the server side the character is already stubned i.e. cannot move but locally its not yet replicated thus it predicts movement until gets the stun tag from server and rubberbands
What is the solution for this?
Unless the client being stunned can predict being hit by the effect in lockstep with their movement prediction, there isn't one
But then how do games like wow or lol handle these?
No idea tbh. Probably use a completely different networking model to UE.
I was thinking of using rpc to add tag on client first and expect a callback
But since the controlling clients movement is essentially predicting ahead of the Server, it won't be able to successfully predict something it doesn't know about.
And a safety to fire on server anyway if client doesn't respond in time
To prevent cheating
This would work, right? Issue is it is 1 ping there 1 ping back in wait time
Client01 can't know ahead of time about things client02 might do to it is the problem
Unless you can predict everything ahead of time, something will eventually cause a missprediction. It's the same reason any Stamina system driven through gameplay abilities has the same problem.
If the ability it's self is predictable, you could opt to use the same conditions on the client as you do on the server.
That is to say, if you're stunned you can't move, and you predict on the client that the unit in question is stunned, as such it can't move until the ability either
A) gets corrected and the stun prediction is rolled back
B) gets the server update and waits for the stun to end
You can't predict in this case because it's another client applying the effet. That's the problem
If the client is applying effects to themselves, that's slightly easier because you can apply them in lockstep with movement simulation
Gotcha. missed that part 😅
I mean like this: caster tells client the intent of slowing target--> server does gas stuff and tells client target that he is slowed--> waits for .2s if it responds stops wait and continues, if it does it slows client target's char on server
But you have no way to predict what another player is doing ahead of time
So caster->server->target->server and if target doesn't respond cast anywas
Im just trying to eliminate the target side jitter
Sounds like a lot of complexity to avoid a small jitter that players won't notice most of the time
I'd probably just increase the amount of smoothing on the target client instead.
I know it cant be predicted in a way to eliminate latency i'm just trying to avoid a correction on speed change
What are the downside of increasing the smoothing?
less accurate world view, less accurate mesh positioning relative to servers actual view of things. Might not feel good etc. Could be a bunch of things but it really is situational
But a client telling the server "slow this other player down" authoritatively sounds like another avenue for cheating, if that is a concern
But as you can see the cloved client was on the location of ggecfire that is spawned at the moment he got slowed
And he got janked back really hard more than 2 meters
Basically that is what i'm trying to fix on high latencies
At high enough latency players will expect things to not be smooth
That's on them really
You only need to ensure a decent experience at the sort of latencies you expect
But it will jank back on lower latencies too just less
So generally it is better to rubber band high latency players than tocwait latency×2 for smooth no rubber banding?
The problem you've got is this, how can one client tell another client "i am going to slow you down a second or so from now" reliably?
Especially when the caster is seeing the target BEHIND time by at least their ping to the server + the targets ping to the server
In my "solution" caster tells server, it tells client and applies on self thus it basically waits the latency difference
But the target is already ahead of the server, by the time that call arrives it's still too late
But sith high latency it can be a 200ms delay not to mention thd traffic
Is it? As target gets slowed before server this was
For ref, if you play either paragon or fortnite with enough latency, you still have the same issue.
You can't avoid miss predictions when two clients are interacting essentially
How high is the acceptable latency for this to appear?
Just have two players walk into each other and witness the chaos unfold, even at low latencies.
It's an unsolvable problem in a predicted server auth model
But it is a physic issue no?
It's the same inherent problem. Two clients are simulating things ahead of the server independently, but every other object in the world is behind them.
Other games like lol or wow cannot send data faster than light either
And they must be server authoritive
Any prediction that needs to reach outside of the movement sim is going to have the same issue ultimately
Game like lol/wow have their own solutions for masking it
But they undoubtably still have to content with the problem IF they do any form of prediction, which they also might not
A quick google search tells me that WOW uses lockstep networking, so they have to hide input latency instead. Unreals' networking model doesn't really lend itself to deterministic lockstep
There's the answer then
If you lag in LoL you lag, the enemy has the advantage because they can do stuff before you do
lol indeed
and you WILL rubberband (dota as well) and see your effect happen and be undone
200ms aint terrible*
Due to the physics laws of the universe we occupy, there's no closed form solution. All you really gotta do is find a way to hide misspredictions as best you can.
What i noticed is that abilities activate with delay
Yeah so input lag
And cooldowns get weird
That is why I thought it works as I said with client->server->target->server
Aka, they're asking the server to do something and waiting to get the data back, so no prediction
Downside of course is, your games responsiveness is dependent on your latency, which for the kind of games UE generally is targeted towards is not ideal
Would this eliminate correction? Is my solution viable?
I'm creating an rpg with button spells
So not a fast paced fps game
i am be out of pocket here, but why would you need a client to predict a stun in the first place?
Predict might not be the correct term
I'm tryibg to remove the rubber banding caused by movneent prediction
im also assuming you mean the client recieiving the hit
As ib the video I linked
Presumably the "stun" effect affects movement
ahhhh
Which is a problem because whoever is moving the pawn is simulating ahead of the server
yea, trust me i am struggling with the same problems lmaoo
movement w cmc and mp is grossly limited
Yes basically the clients jeeps moving as it recives the stun that stops movement too late
And it causes a correction, pretty severe on high latency
But even pn lower ones
i have same issues
i haven't figured out solid solutions
Unless the client is stunning themselves, there isn't a perfect solution. You just need to find a suitable way hide the correction and hope your players are sensible enough to not play at stupid ping
gas seems to be best use case but too complex to redo all my code
and i dont know gas
I'm thinking of solving it via input lag instead of correction
interesting idea
So basically he gets stunned later, not sure itcis viable tho
If you want to use input lag then you can't use the engines character movement system AFAIK.
lmao damn
Not sure if it supports a fully server-auth mode
i thought mover 2.0 was xoming w ue5.4
mover 2.0 will have exactly the same issue
It's not an issue with the way CMC works, it's a fundamental issue with the entire client prediction paradigm
I mean server tells you to stop, target to stop, target stops then calls server back
Just check ping on tick and kick if >55ms
a client cannot predict something it doesn't know is going to happen
Its not predicting
The controlling client IS predicting movement
even more interesting idea
It's movement is ahead of the server, everything else is behind
lmao
But if client is stunned beforecserver it would solve it no? If server waits for target to stub itself, and it recieves client's movement prediction along with the response rpc of it being stunned no?
So you mightvbe stunned longer when you get higher latency but no rubber bandibg
But this is the whole point - how can it possibly stun itself BEFORE it knows another client is going to stun it.
the server would have to tell it, at which point, it's already too late
Stun will be applied with a delay, but it won't cause sync issue no?
As target is told to stun by client it wont move anymore when server stuns itself
Even if you could get this to work, there is no way it's going to avoid a correction in the real world. Perfectly synchronising a timer or delay over a network is also impossible.
IMO, it's not worth the massive complexity to avoid a minor rubber band
True that
Which is something players are already very used to dealing with
And something you can "hide" with some smoothing, up to a point
If in doubt, KISS 😄
Syncing up timers is a non issue, worse latency players will be on the bakc foot iwth longer stuns but still it will look smooth no?
As 100ms extra stun is not too noticable
I've exhausted my opinion on it at this point tbh
A slogan to live by
what is kiss??
"Keep It Simple, Stupid"
Keep it simple, stupid 😛
lmao easyyy
Not meant in a derogatory way in this case ofc
But it feels like we're trying to galaxy brain a solution to an unsolvable problem
of course, and i fully agree w you, i've been focused on this exact topci for about 3 months, i've implemented as much client prediction as possibel and made any addiaiontal movement things either no longer exisiting and replcaed by another mechanic or had something done in cpp to help but yea, the testing at high latenecy wanting zero correction seems very difficult to do without custom cpp work
"If we apply the worst latency to all players!..."
high latency and zero correction is just pointless to even aim for
And players don't even expect it anyway
i think it can actually be beneificall in some cases
To sum it up we either get rubber banded or work a lot to get delay like he gets stunned later
Unviersally all players know that high latency sucks in multiplayer, even if they don't know why
at least latency in general
Players with high ping know they got high ping..
They know they have a lesser experience
In HLL we had a hard cap on something like 400 ping where the game would be literally unplayable
But it broke down way before that usually
Im not sure im gonna fix 200 even 😅
But after 400 or so we wouldn't even accept client shots, just get ignored
lol some things break in mine at even 200ping
Sorry mates but it makes it worse for everyone
lmao same
you can smooth most things out in a fairly regular 30-80 ping game. For parts of the world where infrastructure isn't as mature or if your game isn't that popular you can usually target 100-200 max, but players usually accept the game won't be smooth by then.
Can't really put precise numbers on it though because there's far too many factors to consider
But that'd be my go-to probably
A playable experience sub-100 is good enough for me
im aiming for 200ms ping max, as i said it breaks certain things. not most things just some thigns but 200ms ping would be my cap for ideal highest ping, but i realize i can't stop it completely
testing at 100 or less, it's virtually unnoticeable
i also test w 1p packetloss
tl;dr, multiplayer is hard, make it easy for yourself when you can 😄
Ikr, that is what im trying to jerry rig together with movement
lmao i say jimmy rig
Hello everyone, I have 2 players, one of them drives the car and has access to 4 cameras in the car. My other player is sitting in the next seat and I don't have access to any cameras because I don't have possess. If I do "set view target with blend" it feels like I'm watching the person driving the car and I can't take control. What can I do for this situation?
Why don' you add a camera for the passenger to use?
Itt can just possess a passenger seat that is attached the same way the passenger char iscattacked to the car
And passenger seat had its own cameras
what are the steps for shipping online game? 1. make sure all replicated 2. sessions 3. steam optionally and thats it?
is the OnPostLogin function called only on the server?
yes, gamemodes only exist on server
and not calling Super there also seems like a bad idea
i know i just created this and it worked so i didnt make it yet
if you're creating HUD, make a custom AHUD class or perhaps put it in the player controller
gamemode seems the last appropriate place to create UI
Good to know thanks
Thanks for the idea I will add a camera for passengers.
thats what epic used to do in the tutorials xD
are these 2 equivalent?
Morning everyone. So I'm trying to look at a way to handle this situation, and so far nothing I've tried has worked...
Basically, if a server closes or crashes while a player is on the loading screen transitioning to the server, they get stuck on the loading screen. I looked at using GEngine->OnNetworkFailure and GEngine->OnTravelFailure in the game instance, but neither of those seem to be triggered when I force close a server while the client is loading in... Anyone have any thoughts?
can i trigger repnotify if i set the same value ?
Switch Has Authority is just a check, you can put it after execute on server, and nothing changes. Execute on Server will run things with authority on the server (if possible)
@lament flax not in blueprints. I'm not sure the best way to do this, but for level instantiation I'll start the rep notify vars with things like -99 or a value you'd never see regularly.
okay thanks
what
do new joining players see the effects of old repnotifies?
they only get one variable update, the latest value
if you depend on all previous updates then you'll have to rethink what you're doing
On that topic, can't believe I don't know this, but will repnotify fire on begin play or only if there's actually a change?
To answer your question, you can do this. I feel you were perhaps misunderstood in the conversation above. You can have client A apply a stun, decided authoratively by the server, server will apply a stun ability to client B (the client A is stunning), server will wait at the start of the ability (sync point here) for the client to activate the ability that the server initiated on it, and respond. At the point of responding the client and server are at the sync point, and the client can predictively apply the requested stun on itself, and the server will apply the stun when the response is received. This will allow client B to predict the stun application that was decided authoratively by the server and initiated by client A.
Aside from the added complexity, client A is going to see a fairly delayed stun on client B. So pick your poison
If it differs from the default value you'll get one, and usually before beginplay, but not guaranteed
So the general form to be responsive to data at all times would be:
BeginPlay -> do thing based on state
Repnotify -> do thing based on state
If you wanted to always be set up based on state no matter what.
well you don't really have to do it on BeginPlay, you can just do it in response to the state variable changing, unless you have something more complicated with sub-states
What I mean is what if it doesn't change?
not sure how that last message is relevant, but if it doesn't change from the default you don't get a repnotify until it actually does change on the server
so then multicasts before a player joins are discarded?
yes, I'm not sure why there would ever be the expectation they would be buffered for hypothetical late joiners
if you have it at 0 by default, and there's an event triggered going from 1 to 0, if that event triggers before a player joins, they will not get any update since the default had not changed.
if you have an event on any change, it would also not trigger for the "late joiner" or whenever that repnotify becomes relevant (could be distance related as well)
I don't find that surprising at all, it's the default value
Any multicast you don't know about is gone forever
if you wanted to see a change to 0, you'd want to start at default of -999999999999 or something you'd never see, and then going to 0 would fire off before begin play
(although i believe in c++ you can run rep notifies on non changed variables, but I could be wrong)
But if you are resetting something to a default state, you shouldn't expect it to behave or look any different than how it does by default
So why'd you need a rep notify for that?
0 doesn't mean default necessarily
This is only relevant when a client "predicts" a change to a repnotify variable
You wouldn't, but then you need another initer like Adriel suggested
Beginplay or smth
Prob not beginplay but
What I'm talking about is enforcing the update. Say you had HP and MaxHP. It makes sense to enforce HP <= MaxHP no matter what, even if the default is outside that range.
The weird part is repnotify and arrays
Use nodes like "add" wont trigger it, but doing afterwards "Set MyArray (MyArray) will trigger it
Idk if its BP specific
does a client really need to do a bounds check like that? I thought it'd just be the server enforcing that
Doing "add" will still replicate it
Does any c++ guy can relate to that?
Often you add lots of items to an array, so rep notify from inside a loop would be problematic.
In C++ you can use Fast Array Replication that will tell you what changes were exactly made, E.g. Which entries were deleted, which modified and which added
Is that worth it for something like an inventory?
Seldom changes, and limited size
Guess those inventory structs can be rather large when doing superstructs ;p
Fast Arrays?
Imo, they are always worth it
The only downside is that you have to mark items dirty
But they have better performance, they eat less resources etc.
There are no downsides otherwise than marking items dirty
Iris will introduce them as default, basically. Just without awesome features like giving exact changes
i hope im not interrupting with my question
i've got a small issue i hope u guys are familiar with it :
so in lobby , i have a 3d widget where players can see a list of maps and click to chose any map to load , the issue is that when client click on the map , the string variable stays empty , only the host can chose the map , how do i make the client change the map (string variable ) ?
By map you mean level?
yes
i tried several solutions , but doesnt seem to work , i replicated the variables , and events also
And you want give client an ability to change level on the host?
Then replication won't help you. Replication is one directional - From server to client
You should send a RPC to the server
i did , the run on server and all that
From a client owned actor?
basically a 3d widget that any one can click on , yes
i see
the thing is i was trying to change the level string var through a button press on the 3d widget
if it doesnt take much of ur time , can u direct me a lil bit ?
otherwise i appreciate it < 3
umg -> player controller -> server rpc -> level load from server
i'll give that a try , thanks champ
@dusk fable a pattern like this, don't try to call execute on server from a umg referencing the player controller. - I could be wrong about this, maybe it's a step more than necessary, but it's been working for me
you definitely can directly call a server RPC from a player controller reference
it doesn't matter where it is
A 3d widget in a server owned widget component
i have the widget interaction through the player character bp
i got to work around that
quick question , do i make the "load level event " in game instance , or player controller , or where exactly ? (if theres a diff)
makes more sens to have it in game instance
My issue is that I'm using interfaces to keep things tidy, and you can't make a server call from an interface - afaik
well if it's an interface, sure, if it's an actual actor ref then you can
So is it the invoker that provides the netowner thing for the rpc?
As in, can a playercontroller invoke an rpc on a server owmed actor? Didnt think it could
no?
if the player controller has a server RPC that affects the state of a different actor, sure that works
Right, ok
Thats what i thought. So the actor doing the rpc must be owned by the client invoking it
So for something like a strict server owned actor, the rpc must happen in another client owned actor (typically PC or Pawn) and go from there
Anyone have any luck with switching VOIP settings for things like radios or intercoms? It seems like it requires some sort of 'reset' to be called to actually apply them (or a toggle mute is the only way it works for me)
Rephrase your code to have a Run on Server Event in Playercontroller be how a client requests a map to play.
PlayerController:
IWantToPlayOnThisLevel(LevelToPlay) //Run on server event
Then your widget just calls that.
aight ill try this
The code path should go like:
Widget button -> Controller.RunOnServerEvent //You're on the client here
Controller.RunOnServerEvent -> GameMode/GameInstance/Whatever.ChangeMap //Now you're on the server and can do anything
so on a map click , i set the string var , i send it to the player controller , and from player controller(run on server ) to game instance where the load level event is ,
ill test and see
Is There a shorter way to check if host is Server(Dedicated or listen, doesn't matter) than this?
UKismetSystemLibrary::IsServer(GetWorld())
Something like IsRunningDedicatedServer() without arguments or namespaces
how do I print an on screen message specific to a server or client? I want to debug and see what the value of a variable is on a server and client. Eg I have variable X but when playing multiplayer the value of X is different on server and client
How can I check is client is a listen server or remote?
GetNetMode?
Ty
it's like rebuilding your entire game if you haven't built in a multiplayer flow from the start.
You can run listen servers, but offline / online is locally manipulatable without some central server authority
If you want to make your game multiplayer, you need to consider rebuilding whole communication system. It also depends on how much data you have to transfer over internet, how players most communicate with the server, how clients will communicate about things that are not natively replicated(like ISM)
It will also be impossible to prevent cheating. With a listen server, any host can cheat, and with an offline mode with no external server verification, any player can cheat.
If it's not competitive, that does not really matter though.
Is UGameplayStatics::GetPlayerController safe to use on listen server?
If you're trying to get the local player yes
It's always going to be 0 for clients and the listen server host
I do, ty
You need to get what you have working and start testing in multiplayer right now.
Don't add anything new until you're up to parity with multiplayer.
It'll take you anything from 1 month to forever, depending.
The fact is that nobody is making an uncheatable live service game as their first project
no 1 man team is doing that
probably no small team
you can let people host them self. Use steam to broadcast the games.
As for cheating, read what Adriel says
most people pick a super huge complex game as their first project, learn a lot, retarget and do other projects that are more time / size appropriate until they can tackle the big project
Nothing ventured nothing gained.
But there is certainly also something to be said for tapering expectations, especially for new folks to the industry
Cool. Got a video?
Not yet
Yes
Didn't benchmark it yet, but appeared to be fast enough. Well, at least its not throwing any errors
Also, during benchmark I would also need to make other threads into account. As foliage is generated asynchronously, so not all chunks are spawned synced with the client at the same time
Glad to hear you arrived at a solution you are happy with.
This should also ensure your regular gameplay networking doesnt suffer either
ik. It doesn't throw any errors or warnings
And it can easily chunk data
btw. is unreal's TCP a real TCP, or is it UDP in disguise?
Unreal uses UDP from what I was aware, and adds some TCP-like features higher up the OSI chain so that it can do things "reliably".
for some reason, the shooting isn't replicating properly. When I shoot, on the other the client the line trace comes from their camera rather then the camera on the player shooting
probably not a good image, but it should semi-explain what i mean
Because it is executed on the owned pawn
and owned pawn is player's pawn
so its getting camera from the player's pawn
How would I execute it then? would I have it do a branch to check if locally controlled?
Why are you multicasting this?
Apply Damage will only function on the server as denoted by that little icon on the top right of the node, therefore you only need the server to perform the line trace and call the Apply Damage node. It's also not good to use the nodes that gets player things by index in a multiplayer game. If the server needs to get the player's camera, you should be able to grab a reference to the camera from the character rather than getting the camera manager.
that gets the LOCAL camera manager
I don't mean reliablity and RPC, but the FSocket with TCPListener
which is easier to replicate, animations or montages?
uh
that's not really a real question? What are you actually trying to do?
the easist thing to replicate is just some fundamental state
has anyone encountered an issue where you get a gpu crash when joining a MP match, but works fine if you start it
Sub-atomal 4th dimensional reality
Replicate state, e.g. which frame of the animation is playing
Or rather, at which frame should it start playing
yes
Someone surely had similar bug
More help will cost you 10$ or logs
You can find 10$ in your pocket
Or you can find logs in ProjectName/Saved/Logs
Why does my code doesn't work ? Like I'm trying to disable movement and camera movement when joigning the game level and somehow it doesn't work properly.
On the Client I still can move and rotate my camera, on the server I still can move but can't rotate my camera. It doesn't make sense to me as I thought changing a variable set to "RepNotify" on the server would call that function on both the client and on the server but somehow no and I don't understand why 🤔
All of the nodes on the first screen are on the authority side
Yeah because switching the RepNotify should be done on the Authority side, isn't it ?
So it won't execute on client
Authority means server
I know that
But from what I learned switching a RepNotify variable should be done on the server
Ok, my bad. I though that you are trying to RPC these values to the client
According to the docs, both client and server should call OnRep
link please ?
Found the first issue which is my variables somehow weren't "RepNotify"' but just Replicated. Now it works on the host of the game but not the client joigning for some reason
But I wonder if it does make sense to use an RPC here as to me it doesn't make sense
Even like this it doesn't work. As it's being called by the GameMode which is server only, somehow it works only on the host. I don't understand why
I was right on this
how would you authenticate a dedicated server for an external service?
wdym?
Which type of authentiocation? E.g. QR code? 2Fa?
Ah, this
Idk then, unfortunately
Maybe create a fake client that will be running alongside server, and send rpc with authentication tokens?
Not the cleanest solution
But definitely the dump one
Dont quote me on this but if you are using EOS, I believe it has a mechanism for that?
Maybe best to ask in #epic-online-services
quick question , i have a 3d widget , both host and client trigger click events regardless of whos clicking , is there a way i can make each player control it seperately ? (the widget is for map selection )
Heh adriel NP it was the 2nd part to the simple button problem u helped me with. (Soln: i had to call RPC from player controller and used a interface for bp_playercontroller-bp_button connection)
I owe you a coffee i believe sir! You, Datura, and others really helped me get some practical understanding the otherday. Appreciate you both and others tremendously. I will try to pay attention to your net code reccomends and pop by from time to time 🙂
So what do you have in your OnRep?
What was all needed on the UObject side when wanting to replicate it?
IsSupportedForNetworking? Anything else?
@chrome bay :P your pages cert is invalid
Also, is that even up to date?
I thought one uses the AddReplicatedSubObject function/s now
Ohh thats prob true. My search-fu isnt on par these days, cant even find the post that had the instructions posted a few days ago 😅
I found instructions, but they aren't saying much beyond the functions
They don't talk about what has to be done to the UObject itself
So, one thing I'm not sure about: Do I have to create the UObject locally too?
And if so, what links that to the Server's?
Alright, so either that is said somewhere, or I'm too blind, but you gotta create the locally too, which is what I expected
Well, it made sense to me. I know that runtime create Components also need that
The ue docs generally suggest it
In general, these are the guidelines to go by to determine if you can reference an object over the network:
- Any replicated actor can be replicated as a reference
- Any non-replicated actor must be stably named (loaded directly from a package)
- Any replicated component can be replicated as a reference
- Any non-replicated component must be stably named.
- All other UObjects (non actors or components) must come directly from loaded packages
Followed by
Stably Named Objects
Stably named objects are simply objects that will exist on both the server and the client, and have exactly the same name.
Actors are stably named if they were loaded directly from packages (not spawned during gameplay).
That first point is what I remember. E.g. you can just spawn a replicated UActorComponent and hope it somehow gets created locally
At least we never were able to do that on The Ascent
But that's 4.27, so maybe things changed
What I did now is this
UNKAchievement* DuplicatedAchievement = DuplicateObject<UNKAchievement>(Achievement, OwningPlayerController, FName(FString("AchievementObject_") + Achievement->GetAchievementTag().ToString()));
Achievements.Add(DuplicatedAchievement);
if (OwningPlayerController->HasAuthority())
{
AddReplicatedSubObject(DuplicatedAchievement);
}
That seems to work, cause in one of those Achievements i have a flag that I set to true runtime and print in an OnRep
Perhaps this should be included in compendium 😇😆
Yeah, fixing it up. Classic host provider BS
Yeah it's not really, could do with updating.
I need help. Dedicated server should be able to read the widget. I am not talking about reading another client's widget. I need to just create or construct a widget in the given class and check the default values of the widgets in it. Is it impossible to do this?
dedicated server is headless
if i remember correctly, if you try to create a widget on server it will give you null
Yes but if i "construct" the widget class, i can reach the widget variables. But given variables of these widgets are not correct
what you have to do is :
give client some values and let him check if its valid on his widget
(maybe, prob a better option)
I summarise my problem:
When the game starts, players send each of the slots in the inventory widget class to the server and server saves them to Struct Array. In this way, each client's inventory is created when the game starts.
But I want to add an enemy AI and I want it to have the same inventory shape as the players. Since the AI is not a client, it can never read the widget and send it to the server and have the inventory. In this way, a client has to create a widget for the AI and send it to the server. This makes the system very complicated and long. That's why I wanted to change my whole system so that the server can interact with the widget. I don't know how else I can do it
It sounds like your Inventory actively lives in UMG instead of UMG just representing it
Is that correct?
I want to set the inventory shape from the widget because I don't think I can set the position, shape, default variables (each one has about 10 variables) and size of each of the slots anywhere else but the widget editor. The widget only represents the shape of the inventory and the properties of the slots when the game starts. (As example client checks the widget and says to server that widget has 2 weapon slots, 1 armor slot, 1 head slot). The server saves them to the array once and has nothing else to do with the widget.
There is almost no inventory-related code in the widget. Inventory doesnt live in UMG. I hope i can describe it 😄
I just want the server to be able to read this widgets default values by itself instead of the client sending it to the server
Ahh i see
Show some code
Do you know why it doesn't work ? 🤔
Nothing comes to mind except actor not being set to replicate 😅
Sure.
- Client loops all widgets in inventory tab at begin play, (inventory component)(screenshot 1)
- Client checks variables of every slot and sends them to server to save them, (slot widget)(screenshot 2)
- Server takes it and saves to replicated array (inventory component)(screenshot 3)
So... inventory lives in widget? As exi asked?
That is rather strange
And then inventory comp gets the 'setup' through server rpc's
Yes, because server cant read widgets and player's inventory shapes are stored in widget
like that
But why is client dictating what slots and sizes they gotn
Wouldnt that be servers job?
I determine what the inventory will look like from the widget, how does the server know that?
Not only size and position. I also set the properties of the slots that will affect the game in the widget, like Banned Item Types.
Right. But this could still be provided from the server. Widget just interprets this data and maps them to the slots you have (and resize if appropriate)
So should I store the slot information in a something like DataAsset instead of a widget?
I'm having an issue with this rubber bending on locally cast predicted abilities with GAS
this is how it's called
and as you can see it is set on Local Predicted, using the same movement comp setup tranek shows in his documentation and write the result of if the ASC has the tag the gameplay effect applies
on client if is false both times while on server it is false and true as it should be, but character is only stunned when the server side runs
sorry for the long post but I'm completly puzzled of why this doesn't work
Aren't application of GE supposed to be predicted? are there some pre requisites for this to work?
It's inside my controller and effectively it's not set to "Replicate" should I check that box for it ?
If I:
-> use my PlayerController to Spawn a PlayerCharacter,
-> and then after validating that the playercharacter exists and is possessed,
-> I change a value of a variable inside of that PlayerCharacter
-> Is that enough?
When checking in the PC if the variable is valid, it returns IsValid.
When I subsequently check the variable in the PlayerChar, it returns IsNotValid.
And I do not understand why
I have read the compendium and watched 3 or 4 videos on the topics of multiplayer and replication, but I do not understand why this would happen
If you want it to replicate
It must be set to replicate
Afaik
oh wait, I am setting the variable only on the server, not on the client. I suppose setting this variable to replicated would solve my issue probably
6 times is the requirement these days
Minimum 6 times
Hey guys, quick question, in multiplayer, in a actor class, how do I get a reference to the player character
which player character
Usually a cast suffices
As high as possible
Great question, that's where I'm confused too. Lets say its a 4 player game, and any one character can run into it
Okay, setting the variable to replicated solves my client complaining about the reference being not valid. But it still does not execute the code as I wanted it to
Cast it is.
By casting, does it know what player is casting? Honest question
Also, what if I want to stay away from casting, is it possible to still get current player's reference?
Also, thanks for responding!
If a player is overlapping, then InActor IS the correct playerreference. You just dont know that its a playerreference yet.
That's handy information
Hello.
How do I launch two clients with different user accounts in a PIE session.
From command-line, I can do that quite easily.
start UnrealEditor MyProject -game -windowed -resx=1280 -resy=720 -online -account=user_2
start UnrealEditor MyProject -game -windowed -resx=1280 -resy=720 -online -account=user_1
If you are in the stage where you are not sure what to do with casting, doing multiplayer will really make learning the basic much much harder
because u will be dealing with multiple instances that possibly not sync
Alright here is what I am trying to do;
Goal:
- Upon LeftMouseButton click; Fire golf ball actor into chosen direction.
What I am doing currently:
-> EnhancedInputAction registers input, checks if our reference to our golf ball is valid. If yes, fire the SRV shootGolfBall event.
-> SRV shootGolfBall event checks if our reference to the GolfBall is valid. If Yes, Check if we are allowed to shoot. If yes, Fire ShootGolfBall event on the player character that requested the SRV event.
-> ShootGolfBall event fires, and communicates to the GolfBall actor (That is owned by the relevant PlayerChar) so that it can apply an impulse to the GolfBall Actor.
The GolfBall Actor has bReplicates and bReplicatedMovement both set to true.
Result:
-> All print strings show that we go through the whole flow, yet nothing happens on the screen for the clients. It works on the server, but does not replicate the movement back to the clients.
Anyone any clues to where I am going wrong?
Accompanying visuals in the described order:
Avoid avoiding something just for the sake of it. Be sure you know exactly why you're avoiding it
Curious - why stay away from casting?
Usually to lower the memory usage, in this instance I just want to find which exact character is running into this volume. In single player, all you do is GetPlayerCharacter == and you're good to go, but in multiplayer it's a bit more confusing with authority
that's got nothing to do with single player or multiplayer
also cast to the base class
you can just cast to the player controller (not your custom player controller) and it's free
because your player controller will always be loaded anyway
In this case there's near 0 memory cost and CPU cost. Casting your characters, player controllers, et al, is safe and sometimes even better than using actual interfaces.
youtube tutorials scream AVOID CAST, use Interface
💀
also avoid ticks etc
without context
lmao yeah pretty much that's the reason I got curious 'avoid cast'
Little they knew their entire computers run inside a tick 
Tickception!
In this case they should ofc just cast to Character (or MyCharacter, if theres an equivalent AI/NPC/EnemyBase)
Okay, so turning the very last event that happens inside of the golfball actor to a multicast event allows me to see movement, for the correct golf balls in both client and server.
And I don't entirely understand why this is solving my problem
Multicast (can only be called by the server) will run the function on both server and client machine
if u are doing that for movement, you are probably already doing it wrong
multicast don't really belong to anything that is stateful, because they can be dropped
Right I see, so how am I supposed to this then? I find it very confusing at the moment.
As I understand it, the server is authoritative, and the client is in essence trying to mirror what happens on the server. but how does it do that at all?
How do you handle the golf balls movement?
you have to replicate it's transform somehow
bReplicates and bReplicateMovement are both set to true
if it's a projectile comp, it might have something already for it
but I never touched it so no clue
Actual movement is handled with physics using an Add Impulse node.
that's unknown territory to me but I'm glad I never have to deal with syncing physich because I heard even the battle tested veterans struggle with it
afaik, the physich have some randomness and not that determistic
thats a shame, because that is literally what my entire golf ball movement is based on 😅
well hopefully someone wise have opinion they can share
With using the multicast (even if this is not the right way to do it) I do see quite reliable movement on both server and client, including collisions between the golf ball from the server and the client.
if no multicast, I assumed the golf moved on the server but not on client machine?
Yea true
if the golf ball location is not corrected then the movement is not replicated
So with the multicast
u are basically just telling each machine to do it's own simulation
if physich have some randomness to it, or affected by lag etc
then it's possible that people will see different result
If i were u, I might do it differently
replicate the transform on clients
Handle the Physic in server side
So in client machine, you are only Interpolating to the server's golf ball location, that's it
So server does the add impulse for each golf ball upon input being registered, and then calls a Run on Owning Client event for each golf ball to pass the transform through, which then just sets the transform locally for each client?
Do I understand that correctly?
For clients, I would just interpolate the golf ball location, to server's golf ball location on event tick
I do hope someone else have opinion tho, they probably have better idea than me
So event tick; Server RPC to request the world transform for itself, then set the world transform to that of the servers?
no server RPC
client have no say where the ball should go
it just read a replicated variable
(golf's ball transform)
i would store all inventory data in server and have my widget setup and update using this
Oooo, right! So the world transform of each golf ball gets set to a replicated variable on tick, and each relevant golf ball will pull its own transform data from that variable?
That's what I have in mind, but never done anything like that my self
so who knows what the result would look like
have each player hold a var,, like a int "id"
Right I will do some testing and report back with the results if I get it working
me using interfaces instead of casting to player state, HUD and character :
Don't forget to interpolate, because the server will not be able to update fast enough for the ball to move smoothly in client machine
Check, will do!
Just for verification, something like this right?
So if we have authority, we can set the transform. If we do not, we read from the set transform and interp towards it
Oh! This works 
Probably a tad inaccurate between clients but
Any reason to not do it inside the bp golf it self tho?
Nope, no reason at all. I shall move it 🙂
quick question (not really linked to MP but the next will) before asking another one :
does UE renders all objects in a scene by default, or only renders object that the player see ?
regarding this, i had a random thought yesterday :
- lets say that my player can drop items to the ground.
- right now, on multicast, i run a timeline to smooth the drop of the item from the hand (A) to the floor hit point (+ some offset) (B).
so now, i got all clients doing the animation, and the server keeps track of the actor location
now, my question :
can i make that, the multicast is only run to client that sees/render the item ?
because, the players that are far away doesnt care about knowing the location of the item while it drops, i could set the location only at the end of the drop.
Okay this now all works, with one small exception.
The player can determine how much power they want to apply to their shot. This variable is saved inside of the Player Character seen as that is where the input gets registered for it.
When I then call the ShootGolfBall event on the server, I pass a reference to the player character that requested the shot, from there I can get the ShotPower value.
This however does not work. The server registers a value of 1.0 (the bare minimum). The variable is replicated, so I am out of clues where this is going wrong
For clarification, the server registers the right shot power for the ball shot by the server. It does not register the right power when the client requests the shot
U doing server rpc to tell the server how much it should push the ball?
No replicated variable is needed
Player input pressed -> server rpc, shoot ball (have float input that represent the velocity) and just pass the value via rpc
I can't pass the player ref in the server rpc, and then pull the float from there?
Thanks for answering, can you demonstrate how I'd do that?
Yes u can
U can pass any data u need
But if u are client, your rpc gonna get dropped in actor you don't own. So route that to something you own like player controller
Anyway gotta hit the hay. Gl to you
Thanks for all the help!
It's as simple as, player input pressed -> run server rpc which takes a float or any variable u need to push the golf ball
Yea I think I understand now
It works 🥳
But only if I pass the shotpower float into the server rpc directly. It does not work when I pass a player char ref into the server rpc, and then based on that retrieve the shot power.
Hello 👋
I am trying to update my player velocity in air if no inputs are pressed, it's working perfectly on standalone mode with a single player, but in multiplayer mode with some network lag (average settings), my client is jittering until the server receive the new velocity, I tried by using RPC and FSMN_NetworkPredictionData_Client but it still jiterring, do you have a hint to help me please ?
The server would have ref to every controller and character, if done right it shouldn't be an issue 🤛
Gotcha, I might need to dive into more then in the future
Ofc server will get a ref to the character that it has in its own world, so the power in the character on server version would be 0. Your method of passing the velocity or power should be a server rpc.
Remember that the only way for client to communicate to server is via server rpc
Ah right! And because I have only set the shot power locally, and never told the server that the client has changed its shotpower for that player, the server doesn't know about it