I agree
I was thinking
Multiple Full Stacks with Matchmaking
this section in
https://docs.unrealengine.com/5.0/en-US/hosting-and-networking-guide-for-pixel-streaming-in-unreal-engine/#multiplefullstackswithmatchmaking
in this link , does it help me achieve what I'm trying to do
#multiplayer
1 messages Β· Page 19 of 1
Ah, yeah my bad. It was the net id. GetUniqueId()->GetBytes() as a uint64 is the player's SteamID when using steam. Not sure how that turns out using NullSubsystem
Do you know if there is a BP equivalent to GetBytes?
I can access the func in BP, but I can't do anything with the output
How would you spawn a level dynamically in multiplayer? Spawning it on both client and server, it will create a duplicate of all actors (even replicated ones). Creating it only server and it will not appear on client
I'm not sure how the level transitions are handled tbh, I joined after that was already finished.
Not likely, uint64 isn't supported in BP I don't think. Only int64
f
Alright, thanks for letting me know
Well.
Not sure if I'd rely on it for more than visual or testing, but you could wrap a library function out of it and return it as an int64, or even just a string of numbers.
Would be easier to make an == if there isn't a bp exposed one though. Would still require a library function I think.
Thats a pretty good idea actually. Make a C++ function library, give it a function UniqueNedIDStructureToString or something
Sweet, that worked perfectly, thanks a lot
Yeah but that needs you to launch an instance per player after all. This doesn't save you resources.
You basically become Stadia for just your project
Image get updated in clients, but not in server, what am i missing ? ^^
also tested without RPC, same result
Could be as long as you seamless travel between those levels.
It probably won't persist between two sessions
Probably can't call Server RPCs on whatever actor that is
it's on the player controller bp
Oh wait
It's because the Server RPC isn't doing anything
It's just calling the client RPC
No you shouldn't
UI should live in the HUD
Actually no. Seamless travel doesn't work in PIE
Also, very odd to have RPCs that update the HUD directly
HUD should be driven from gameplay
im not familiar with hud :C
always created widgets from pawns or player controllers
HUD is just a convenient place to store widgets, and it's easily accessible from the controller
The Server shouldn't see any of the clients' HUDs anyway
yeah thats what i was wondering
The HUD is pretty redundant. You just use it as a storage
yea , thanks for clarification
i will see if doing the stadia type of setup works for our usecase
cause it doesnt have to know
State should be a replicated variable
Unreal Slackers
Support and resources for the Unreal Engine community. Get help, share your work, discuss the latest news.
β
Members: 82,267 β’ 6,773 online
Boost Status: Level 3 26 Boosts β’
Created: <t:1464706564> β’ <t:1464706564:R>
Invite: discord.gg/unreal-slackers
β
Website β’ Twitter β’ GitHub β’ Donate
Anyone knows why actors spawned from a template in the SpawnParams don't get replicated?
Is it spawned on the server, is the template replicated
Yes and yes
idk then
Oh, never mind. I figured it out
What was it?
It get its template from a server only level and thus spawn inside that level which the client doesn't have
Can you change an actor's level in runtime?
Actor->Rename((const TCHAR *)0, NewLevel); //Set the outer of Actor to NewLevel
NewLevel->Actors.Add(Actor);```
Seems to do it
SpawnParams takes a Level param
You gotta be real careful about renaming objects at runtime if they are replicated
Still doesn't work unfortunately.
{
UWorld* World = ActorToCloneFrom->GetWorld();
FActorSpawnParameters SpawnParams;
SpawnParams.Template = ActorToCloneFrom;
if (NewLevelOuter)
{
SpawnParams.OverrideLevel = NewLevelOuter->GetLevel();
}
AActor* Actor = World->SpawnActor<AActor>(ActorToCloneFrom->GetClass(), SpawnParams);
return Actor;
}```
I tried this and the actors that get cloned, doesn't get replicated π¦
Yea, real odd :/
I need to copy the actors from the sublevel to the persistent level
in runtime
Isn't there a function to move them into different levels?
I've tried to look for it, but can't find much
I have these levels that are point of interests for our procedurally generated world. But I only use them as templates to copy from in runtime
Making a whole science lab room inside a BP is a pain
Try to set bNetStartup = false for the template before calling SpawnActor.
{
UWorld* World = ActorToCloneFrom->GetWorld();
FActorSpawnParameters SpawnParams;
SpawnParams.Template = ActorToCloneFrom;
if (NewLevelOuter)
{
SpawnParams.OverrideLevel = NewLevelOuter->GetLevel();
}
ActorToCloneFrom->bNetStartup = false;
AActor* Actor = World->SpawnActor<AActor>(ActorToCloneFrom->GetClass(), SpawnParams);
return Actor;
}
return nullptr;```
Like this?
Yeah. May work.
Gonna try! I've asked on UDN now aswell π
See if we can get some answers if this doesn't work
Ah yeah, that makes sense
Might someone be able to solve this for me? I have a UI (A), which is owned by my player controller (B). The player controller created an AI char and AI controller (C and D), and set their owners to the controller (b). The AI char (c) has a replicating component (X). Problem: calls from the UI don't fire server RPCs on X
You cannot call RPCs on things you do not own.
Has to be PlayerController, possessed pawn.
It is a possessed pawn
It's not possessed by the controller with the UI tho, since its an AI
Possessed by the player
Even with 'owner'ship set?
PlayerController, pawn possessed by that PC, or actor with ownership set on the server to that PC
oh, so 'an actor with ownership' excludes possessed pawn
so, what option do i really have, besides what im already doing:
The test is "is this actor or component owned by the PlayerController running on the local client"
On the left, i have to make an RPC on my controller, for every function i want to call
The 'remove item' will get the same treatment, 'remove item on server'
Either possess that Pawn directly from the PC, or go through the PC for RPCs
I'm working with the common 'top down for multiplayer' setup, that has a pc and invisible pawn, then an AI controller and char to appear as though moving from replication
Possess shouldn't matter if ownership is set.
Not sure what the AI controller is for, really
all the ai controller/char does is move to location (which happens on server)
AI controller is specifically intended as a player replacement
mostly to handle things like move to on right clicks
Datura. I've gone through every step of the chain and i feel like it should work...
ive even put ownership on the widget
The widget is irrelevant
You simply cannot RPC through an AI Pawn
Either possess it directly, if you only have one pawn per player; or go through PC
Does Daturas comment support that? It sounds contradictory, unless im reading it wrong
I guess Datura is saying that you don't have to possess if you set up the authority
If you do possess though it has to be the PC
gotcha
Can i get away with.... unposses(), func(), posses()
sounds awful to do every call but...
Either possess that Pawn directly from the PC, or go through the PC for RPCs
You simply cannot RPC through an AI Pawn
The pawn has to be PC-possessed
AI Pawns can be owned and RPCs can be sent through them.
You can't send RPCs through an AI Controller as the controller only exists on the server.
AIC isn't replicated so no shit
Yes, you "can" RPC through AI Pawn, just change the ownership every time you possess it
Or, hear me out, design this properly in the first place
if you google 'unreal top down multiplayer' there are 100 tutorials guiding to this exact setup
not saying its the best, but its the starting point for a lot of people
so, i was wondering if it can actually be made to work
Just because lots of people teach something doesn't mean it's the best thing to do
Anyway, feel free to hack your way through the engine's design, I'm just trying to point out the easy and widely used way to design around this
as this has an owner set, unpossessing would leave my controller as the owner i imagine, right?
No
APawn::UnPossessed specifically nulls the owner
The initial owner of a Pawn is quite meaningless
Pawns are managed through possession
How about multicast.....
i suppose an action like inventory management would actually be? or no?
and that i could call from ai pawn?
or am i just making you madder by typing that π
You can't fire any RPC from a Pawn you did not possess (or hacked your way through ownership disregarding the engine's design)
You have three solutions: don't use the bot system (AIController is meant for shooter bots), or use the common method of routing RPCs through PlayerController with an interface, or hack your way through something
so the passthrus ive been doing is actually something others do?
it feels like its just going to go on forever tho
You don't normally have dozens of independent classes that are server-owned, but player-controlled
If you're doing a top down squad-based cover shooter or something you'd have a "send pawn to location" RPC on PC that would take a pawn as parameter
If you have usable objects you'd have an "use" RPC with the object
etc
I mean having RPCs is a fact of life - your problem here is that you're trying to control things you do not cleanly own
yeah. i stopped work to try and figure out the right way to be doing this
and it doesnt sound like its going to as is
The way I see this, a third of those look inventory related (put that in your player-owned replicated inventory component), a third are normal player stuff (saving, loading) and the rest are things your unpossessed (no AI controller), player-owned pawn could do
They're all calling inv component functions, because I couldnt directly
Why not though?
Just move that RPC to the component
You'll always need an RPC of course
That's just normal
not sure i follow. i had the rpc on the component, but i cant fire it
because its not owned, as per this whole conversation
Your inventory component should definitely be owned by the PC
Or the Pawn, which should be owned by the PC
Then I'm going back to my original point: remove that AI
right
Either possess (one pawn per player) or don't (>1 pawn)
But cut the AI
It simply doesn't fit the design
Or live dangerously and keep the AI but try to force the ownership after possession, but like I said, I wouldn't like that
Hi everybody!
I'm just figuring out AI and my setup is local multiplayer do i need to take anything extra into account?
As far as i know, the AI Controller runs only on server, so it should be all the same, right?
I have an rpc function like this cpp UFUNCTION(Client, Reliable) void ExampleFunction();
I call it on the server and to make sure its a server i do cpp if (GetNetMode() == NM_DedicatedServer) { ExampleFunction(); } But its executed on the server, is that normal?
I tried both in Standalone and viewport mode, im using "Play as client" netmode
hi does anyone know anything regarding crack protection in multiplayer servers?
I get that for singleplayer u can't really do crack protection, but it might be possible for multiplayer, what do you think?
with Steam.
I was thinking that the most common way to crack MP is to emulate Steam right like you own the game?
but maybe the server can check if the player owns the game on steam somehow
not sure which channel to post cuz it kinda relates to both #multiplayer and #online-subsystems
With Steam you can validate players who log in to your game and check if the account they're using actually bought the game.
ok yea that's what I was thinking, do you know how I can do that ?
preferably with as little CPP as possible XD
To put it plainly, the only way you could guarantee that the player has indeed purchased is if you control the servers they are connecting to. If you allow players to run their own servers then someone will be able to break it so the check doesn't do anything.
Yep
but then can I package my key into the game or will people hack it and valve will scream at me?
or do I need it to be like a separate file that I only put on my servers
If you give away your keys, you're giving them access to muck about with how your game is represented on Steam.
well it's just the api key
but I guess that answers it I can't put it on the client okay
but isn't there anything I can do for serevrs that people host?
for example in ARK, it's super hard to crack it to play multiplayer
how did they do it
you have to download like a whole bunch of shit and it's really complicated to play online on cracked
All you can do is deter and make it difficult, but not impossible.
Once you have something running on someone else's hardware, they have the means to mess with it and break whatever security you have in place.
That's not something I'd be able to answer myself.
Sadly, you probably won't find any answers to that either, as even discussing "how" someone does it effectively reveals the key to how to break it π
: - (
Hey Guys, i have a project in which OnlineSubSystemforSteam is used for building a listen server based game. Bow I want to remove the steam server code and build a new dedicated server with the same game logic. How hard will it be and are there any resouces to similar projects? What will be the steps to be taken to successfully build a dedicated server from a listen server project? Thanks in advance
For starts I'd recommend avoiding Dedicated server checks unless it's for some form of optimization. Like not having particles or sound. If you want a server check then do GetNetMode != NM_Client. Anything except for a client is a server.
As far as a ClientRPC running on the server, yes that's possible. It will run on the server if the thing it's on is not replicated, it will run on server if the thing is replicated and server owned.
< NM_Client is always some form of server. There is a netmode that is > than Client. It's not used anywhere, but you never know π
Aha, the issue is i was calling the rpc too fast, had to wait till the client was setup
The thing is i want it to work with dedicated server only, not sure if its a bad thing
Dunno. Not sure what you'd gate RPC wise for a dedicated server only. I would personally prefer to keep options open. Your net code generally should not really matter if you're running Listenserver, Dedicated, or Standalone. The specific checks like Dedicated are usually only ever used specifically for optimization purposes. Keeping the server from creating costly materials, doing unnecessary visual setup code, etc. And that all just gets checked locally in some functions, it's not really netcode as in RPCs usually.
Isnt there a way to prevent a code from executing on server no matter what?, GetNetMode doesnt help, code runs on server even if NM_Client, will #if !WITH_SERVER_CODE or #if !UE_SERVER do the job?
Only if you compile a dedicated server
Great to know, one more question, does #if !WITH_SERVER_CODE or #if !UE_SERVER Disable the code block or removes it completely for dedicated server?
removes it completely
hello i have a character that has a cube attached to the camera and i want both clients to see the current rotation of the cube. I set the camera and the cube mesh to replicate and launch a listen server and the rotation done on the listen server client are visible on the other client, but not the other around. why is that?
also, if i set to dedicated server, only the local character has the cube rotation set, so it's the same problem but for 2 clients
i can fix it on the listen server if i do a server rpc to add controller pitch input on the server instead of the client, but shouldnt the add controller pitch input on the client do that automatically?
Using RepNotify variable for my character's healthbar. Working perfectly.
But it doesn't get updated at the begin play.
Do I really have to SET the variable at Begin Play ? Or is there a better way ?
i mean the default value of the health variable is the health i want him to have at BeginPlay
Well the OnRep doesn't call for the initial value unless it's changed
So in your healthbar you just get the current value on Construct
Allright, then doing THIS, despite being more convenient than creating 2 RPCs ^^, is the way to go ?
When i do it in construct, it is too soon, it doesnt work
^^
That is not needed
The proper way of doing that is getting the value on Construct and listening to a delegate
i see
For future changes
If Construct is too early then you have to manually init it whenever it is not too early anymore
How comes we cant set an image variable in a data table ?
Image variable?
Show the variable type
That's probably a UImage which is a pointer to an image widget
What you want is either a material or a texture 2d
is the most up to date example of a repgraph still the shootergame one? I didn't see one in lyra
there is UBasicReplicationGraph but I'd like to see a more game-specific example
Hi, simple question: if i run a multiplayer game with 3 players, how many PlayerController do i have? Only 3 for each controlled Character or does every simulated proxy has an PlayerController as well?
1 controller for every connection. Dedicated servers don't have a controller
in my case (listen server) this means 3 controller. So if i run code which requires a valid controller it will not run on the proxies?
You can think of a controller as like a Playstation or Xbox controller or even a Keyboard+Mouse combo that a real human uses.
A human only uses one controller at a time, but maybe you have a few different ones in your game for them to use at different times.
It will run on everything that isn't a dedicated server
@odd ruin do consider watching this in the future.
https://www.youtube.com/watch?v=JOJP0CvpB8w
An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.
Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe
00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...
simple example: if i run the simple code: if(PlayerController) { do XYZ;}, will this line excecuted on the proxies?
I have watched it at least 5 times now and learn something new I didn't understand before every time
again. Yes
i watched it already...and will watch it right now again π
awesome
Also this code doesn't really make sense to me
unless I'm over thinking it... But I'm pretty sure you would want to check if it's not the dedicated server
and if true; then you'd get the reference to the controller -> and then do XYZ
π€ controllers exist in server and owning clieeeent π΅
To ensure that a controller is local you can check IsLocalController π΅
the reason i am asking is, i am trying to pass the MouseCursor position to the server and from there to the clients since this is the position where my bullets go (TopDown Shooter).
that's okay, similarly onclick or ondrag you can forward to your server controller input data
either would work honestly
as long as it's not the dedicated server then we know for a fact a controller exists
dc server or not the server will hold all the player controllers
indeed, that wasn't what he asked though
If you're having trouble, the method would be to replicate an event from client to server on tick that holds the vector of the mouse location. From there you'd want to multicast that vector to everyone
server rpc first if not authority, and then replicate if stateful, or multicast rpc if transient (in case you want to forward this input data to the other existing connections)
thats what i am trying without great success yet...sometimes its the easy stuff that gives me headaches
take a little read to my article, towards stateful replication, maybe it helps to grasp concepts of transientness vs statefulness
Thank you
no problem, regarding specifics, replication on an actor channel that is replicated only to the owning connection will have no effect over simulated proxies
Player controllers don't exist on other clients so what's the point?
True! this wouldn't work in the player controller. Perhaps I'd put it on the clients pawn
though the concept remains the same
that's what I mentioned above
I'd replicate a variable myself but either or will work
replicated variables are reliable
:p
at least it's never been unreliable as far as I can tell
thats excactly what i do in C++. And in the curser location i pass the location from GetHitResultUnderCursor()
yeah you can't do it in the player controller, I don't know how I forgot that
put it in the pawn
it doesn't work because of this: #multiplayer message
the way you explain things are really complicated. You could also just say "player controllers don't exist on other clients"
I said it π
you right you right
problem is...
i like to be a bit of a goofball when explaining things
cause I enjoy multiplayer a lot
π€£
How would you do multiplayer procedural map generation?
you want to kill me right π€£
- Do heavy math on server, replicate result
- Replicate seed, do math everywhere.
soyougenerateaseeddeterministicallyoneveryasblablah
In my case result is MUCH smaller than the intermediate stuff
but it'd still be replicating say 5k actors of various complexities at worst case
individual walls and doors and windows etc
you can always route replication through a network manager π
but I get it
it's a PITA
as long as your profiler doesn't yell at you for your use case
it'll be okay π
you can actually leave these optimizations for a later phase if needed
This isn't our project but targetting about a square km map at this sort of density.
you might want to speak with le kaos and le zlo
they had to deal with a similar complexity pretty recently
OMG i made it. Thanks for you guys help. Short version: if(IsLocallyControlled()) {Get the Mouselocation from the playerController; Than Call Server RPC with passed in Mouse location; which calls MultiCast RPC with the Location}
You making yakuza 7?
Nah a roguelike top down shooter
Sorta like a live-action XCOM is what we're going for
I want them to connect directly to their friends on Steam by inviting them through the lobby. The invitation goes to the person, but when he accepts it, it does not connect to the map automatically.
FriendList Δ°nvite button
Host
Friend Accepted
FriendList
What is wrong or missing?
You have to travel them to the session being hosted once you "Join Session"
Is there a guide on how to do this?
Have you checked if the session join is failing?
I don't know exactly as I didn't put the invite accepted print string
If it was successful, wouldn't the session join?
Poping a little text BP when Overlapping my shop. I set the shop NON replicated, as i think its not necessary ? I need every player to see his "personnal" text widget when approaching, just like this :
But somehow it messes up with clients
(the textBP im speaking about is the "Press C !")
Also tried with setting the shop REPLICATED, and with RPCs, same result
Shop should be replicated, the widget component should not
I made progress doing that
locally, the shop displays the widget component when CONDITION. The server doesn't know or care about it.
but when playing as client, server still sees the widget
btw its a BP with text render, not a widget
Show the logic chain between overlap and showing the thing
Cast to YourPawn and then check if it's locallycontrolled
You'd doing that locally yes, but on the server AND client
btw that's gonna break when you have 2 clients nearby
Actually it might not as long as you gate by if the ship is locally controlled for all entries and exits
when approching the shop with server's ship :
Yup that's correct
and btw
i intend to create a respawn mechanic when a ship dies
ive done it before
and when it happens, its not locally controlled anymore
i dont understand shit about this
but that's another story
Thx for the help, it works now
how to get a list of playercontrollers in C++?
Currently worried about the respawn mechanic
in C++ ? π Cause i can tell you in blueprint
In game mode, on "Event PostLogin", you need to add the incoming player controller to an array
And "On Logout", remove it from the array
well i think you just have to find the corresponding C++ functions
of what i just told you π
i dont know any tutorial for c+
GameMode => Event Post Login, and Logout
ty, I found it
π
Hey folks, I'm trying to get my hands on modding the Unreal engine 3 and on a tournament 3 or the Unreal development kit, something like that. I really want to mod the game, any of you can lend a hand in an advice, what would be the best option? Also yes I know the engine's longer used. I'm just trying to mod the game, any tips or advice?
We're not really a modding community!
After adding the advanced session plugin to my game, the game does not work when rendering, what is the reason?
It works fine when rendering without the advanced session plugin.
for multiplayer, is it better to cast to APlayerController or AController when you are storing the players?
depends what you need, but i would store your custom player controller type for ease of use, instead of the base APlayerController or worse AController, but again it depends what you need
sorry I don't understand
do you have a player controller type that you have made?
you mean MyCustomPlayerController?
yes
no i didnt make any custom player controller
ohh ok thank you
Also what code do you place in a playercontroller?
do you have an inventory component?
i doubt you can add an inventory component
personally i would make this on the character instead but like with everything it can depend on what you want to do
i mean i never tried
having it on the character means that possessing other characters will not persist inventories and such
yeah
Thank you
What code do you add to ACustomPlayerController class?
like no code at all or?
like maybe owning pawns if its an RTS?
or its on the default pawn
whatever code is needed for the player controller? it will persist across possessions and afaik its supposed to be like the "will" of the player. eg what the player wants to do. think of it like the actual person themselves. what info do they need? maybe some OSS stuff?
ahhh ok ok thank you
now I get it, when you said its like the player itself and his will π
like OSS stuff
Separation of code in regards to the player controller usually is a bit easier to understand when dealing with multiplayer, but ideally Player Controller should be used for any controls that do not pertain to the specific character they are possessing. An example would be like an input for a pause menu. If you're making an RTS game, then you're probably routing most of the controls of your units through the player controller as well since you're probably not directly possessing any of them and are instead issuing commands to your units who then have an AI Controller that handles the commands.
What WOULD your pawn be in an RTS anyway? Camera?
Yeah probably
How expensive (Bandwidth) is it to replicate whole Actors (i.e. Weapons). Should i avoid it if possible or does it not matter?
Actors are replicated all the time. If you're worried about the reference to an actor, it's small (like a few bytes small)
Depends on the additional data in the actor. What usually is way worse is the ms it costs to consider the actor for replication. Tweaking some of the replication numbers for less important Actors is a good idea
ok, thanks
guys if I want to make a player own an actor/pawn i just need to SetOwner(playercontroller)?
for lets say RTS
SpectatorPawn?
A camera that contains a list of selected units i guess
I tried to build a dedicated server for a multiplayer grame having steam engine listen server. I tried removing the steam onlinesubsystem plugins and configuration from defaultengine.ini file. But I am having a few issues. One of them being the lobby game mode not working when lobby is set as the default server map. In the server log, I am getting the following error, βLogNet: ReplicationDriverClass is null! Not using ReplicationDriver.
Any idea why and how to resolve the issue?
Good morning everybody
I playtested my game yesterday on a server
It was great fun
My code is incredible
120 ping but smooth gameplay apart from what isn't
R u testing on 2 separate devices and 2 steam accounts
And in packaged or standalone
hi, im testing on the same device in standalone and packaged modes. I no longer want to use the steam subsystem and wants to remove it and buiold the dedicated server. Any idea?
Do I get it right? In the network compendium it says that a non-seamless travel must occur
- When loading a map for the first time
- When connecting to a server for the first time as a client
- When you want to end a multiplayer game and start a new one
Means, that if I travel from my lobby to the game map, I need to do non-seamless travel? Since it didn't get loaded before.
Pretty sure it's just the first map your game load, as in the menu one
If connected to a lobby on a server, traveling to a different map can be seamless
ah great. I was already a bit confused, since it would make seamless travel useless on my end. Thanks π
yeah, should AFAIK just be the initial connection to the Server - so long as you stay in that server everything can then be seamless from then on
Hey ! Using RepNotifies to update a widget component above head. Life is a Float variable, and everything is working fine.
Level, however, is an Integer, and the widget component update only on Clients. Everything is set up the same. Are there difference with Integers on RepNotify ?
noop, should be the same
When changing the variable to a float, and making the rights move to repair nodes involved
it works
so it must have a difference
My level get updated on the server widget component when it's a float
very strange behavior
I'm thinking of renting a virtual server, which Windows Server version would be better for me to rent? 2016, 2019, 2022 or does it matter?
The newest I guess. But I would suggest you check if Linux works for you. They are overall cheaper
+1 for Linux VM's
Most dedicated server stuff is done on Linux. I like DigitalOcean for a cheap test server.
Also +1 for digital ocean
Hey guys, could someone tell me what would be the best way to store data for a non-seamless travel? Lets say I have a variable in player controller, where should I move it so that its value should not change? I might have multiple game modes
game instance ?
its data seems to get changed tho
As much as I know, if you want to host something without having it destroyed then you use game instance, i think that it applies the same with variables
for example, multiplayer
the session doesnt die
if you cant find anything useful, you can save it on a file
ask again cuz i didnt solve your problem π
sorry
its all good, I'll try something new on a new project and then see what might be done
when we run a dedicated server, do we have to make each server use a different port when using the same game? I have a problem if I launch 4 different servers and 4 different game modes everyone can only join the first server I run
even though all the others show up...
If it's running on the same computer, then yes, different ports for each server.
When using dedicated server (testing in editor) client 0 is extremely laggy, but every other client that connects is fine
@sinful tree I tried different ports but it still only connects to the 1st server that runs
I start my server with a bat file is this the correct way to do the port? -Port 7778
I want to invite my Steam friends and join them directly from the steam interface. but it stays in the main menu. Session not connecting
Host
Accepted
FriendList
FriendInvite
where is my mistake or omission?
-port=7778
Design question - Let's say my character has 8 skeletal meshes which make the body. (Head, torso, hands, gloves etc) Like Fortnite does.
Would you create 8 separate replicated FSoftObjectPath in the character class OR would you wrap the 8 FSoftObjectPath in a struct and replicate that.
My first instinct was to wrap them in a struct with ReplicatedUsing, but then it's a bit annoying to find out which one of the 8 values changed.
has anyone seen a method for replicating live link data across a multiplayer session (e.g. body/face data?)
i have TArray in Actor Component replicated and acting as proxy for my subsystem
is there any way to find out what index was modified when repNotify fires up without parsing it with a previous copy in my subsystem?
You have the param of the old value in the OnRep function, i.e. OnRep_Blah(OldValue)
would be better if you replicate some byte values and change the mesh based on those numbers.. always try to replicate less data~
Yeah, I should make a table and index it, but as it stands right now, the changes are so infrequent that it should not matter in the long run.
Right, I can just check it against the old value. Thanks for the suggestion
is this the correct way to set the ports for unreal egnine dedicated servers?
is the append node correct? Is it suppose to open level by name?
You can use the port argument when starting the executable for a dedicated server. https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/CommandLineArguments/
EmbryosServer -log -Level=Complex1Hunt -Mode=Hunt -ServerName=TDM_Server_Long_Beach_NY -port 7778 -AUTH_TYPE=deviceid -AUTH_LOGIN=test -AUTH_TOKEN=test -MapRotation=Complex1Hunt
pause
I have it coming out into the host
and then into the open level by name
but its not working
am I doing something wrong?
this code is not working. I can invite a friend on Steam, but nothing happens when they accept it.
@oak prawn did you put the steam 480 file in your folder?
yep. The code of my game, which is currently on steam, is written in txt
you might need the fix https://sbcomputerentertainment.com/other-2/multiplayer/how-to-integrate-advanced-sessions-and-fix-steam-on-4-27/
i dont know if your using version 4 or 5
but we needed to use advacnced sessions
5.03ver
maybe you should try that and see
Hello, I have problem with placed actor in the level.
when I place a replicated actor in the level, the repnotify functions seems not firing when variable is changed on the server
only does if I spawn the actor on the server
the variable is stored in an actor component
I have no such issue with variable in the actor itself
dont work
Actor component replicated?
Show your replication settings from the actor down to the variable. Actor, component within actor, then variable inside component
which component is it
AC_Inventory
does the value replicate out and just not fire the repnotify?
I think is repnotify not firing
I use it to refresh client side inventory UI
When manually call a refresh function on the client, the repnotify variable is indeed changed
Show the repnotify function
Or just have it print a string to see if it's even firing
You don't know if it's not firing or if it's just not doing anything useful
Don't do this
but this is even after print string
Just nuke all that and remake the repnotify and have it print a string
ok
same thing
it only functions when I do this on server.
doesn't work when actor is dragged into the level
of course I can use a walkaround to place anchor points and make server spawn the actor
just want to know what is causing this issue.
I'm able to reproduce the problem. It's very strange
That OnRep variable is an array of structure. If I only change the structure within this array. OnRep doesn't fire.
If I add an extra index to this array. OnRep fires.
It's Blueprint structure, so I did not mess up anything with c++ structure define.
BP structs are kinda scuffed anyway
maybe I should submit a bug report
Hi! does anyone know if there's some free API to generate multiplayer chat in-game?
So different sessions just hit the API and get updates from it when you are on.
is there anything I can do to reduce the ping I get?
or is that only related to the location of the server vs client
Pretty much.
I mean there's connection quality etc
I get like 100-140 ping between Israel to United Kingdom (4 hour flight). Does that make sense?
I feel like that's really high
That 100% depends on your network conditions and there's nothing software you can do about it.
okay thanks
as a benchmark of what is "possible" you can take popular video game pings metrics.
Someone from South America playing in CS GO/LOL European servers will get around 150 pings
@past totemI bet half of your ping is between your machine and the ISP and the servers machine and ISP
Tracert it
can someone please help, everything is so confusing, spaces before the append, spaces after then append, now I read something and I need an equals sign? what is the correct way to set the bat file for the port? I have this set up with the bat and it works but Its not working with the ports, is -port 7778 ok, or do I need -port=7778? I cant run more the one dedicated server on a PC unless I tell it what ports to use. do I need any - in the append any = in the append, is someone could help and post the code on the paste bin to help out, it doesnt want to connect to any other server but the first one I start because of this port issue
cd %~dp0\NewKaragon\Binaries\Win64
start NewKaragonServer -log -port=7887
I have 2 questions:
- where do I store my clients data, before they join a server and after they join a server. As long as the game is running the data needs to be present there?
2)Where do I store my server data, as long as the game is hosted, even if it changes the map?
I would look into GameInstance
It persists throughout the whole playing session
what if a client starts the game, there is information to be stored, does the game instance work for the clients? Can they grab those information?
Lets say a client is on the main menu and stores some data.
Now the clients joins the server, can he retrieve the data that he stored in the main menu?
Yes, that's the point of the game instance.
However, its obviously not replicated, this is local to each player.
ahhh thank you very much for this one
My game has better fps in single player compared to playing on a server, does that make sense?
Has anyone ran into multiplayer issues with world partition? I feel like it gets laggier the more I explore, like the chunks won't unload or something.
Dedicated servrr
Profile your game/server and see what comes out of that π
hiiii can you tell me how tho? like I have no idea how. also I'm testing in packaged, not in editor
Yes because of netbroadcast tick. It eats away at your frame budget.
You can test with the net profiler
auto AICtrl = Cast<APhobosUnitController>(Cast<APawn>(Actor)->GetController());
this fails on clients, and i cant seem to find the problem
to be precise, it stops a for each loop when i hit this line???
for (const auto Actor : SelectedActors)
{
if (!IsValid(Actor)) continue; // Skip null actors, they shouldn't be in the list anyway.
auto AICtrl = Cast<APhobosUnitController>(Cast<APawn>(Actor)->GetController());
if (!IsValid(AICtrl)) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "Invalid AI Controller");
// We create a new command object, and wrap it in a USTRUCT to be able to pass it to the RPC function.
// TODO: This is just a prototype
FUnitCommandMoveToLocation* Command = new FUnitCommandMoveToLocation(FMath::RandRange(0, 9999), AICtrl, FormationPositions[0], Direction.Rotation());
FCommandWrapper CommandWrapper = FCommandWrapper(Command);
GiveCommandToActor(AICtrl, CommandWrapper); // Call the RPC function
FormationPositions.RemoveAt(0);
}
it executes properly on the server
hi thanks, can I get the net profiler on a packaged development build?
To do this, you need to use a version of the engine with stat tracking enabled I don't know if this includes development builds
and do I need to do this network profiling on the client, or the server?
okay apparently i'm crashing the server, that's why it stops
Possibly null pawn
Note AI controllers don't exist client-side
oh great, thats all the info i needed thx
Can anyone explain why get player controller doesn't work for multiplayer? What am I supposed to do instead?
The network compendium explains why: https://cedric-neukirchen.net/
Often enough, you can just do a regular GetController call anyway.
What is the difference?
It'll only work for the owning player because they aren't replicated to anyone else. Use player states instead if you want to share info or whatever it is you're doing.
Or pawn etc.
How do I run netprofile disable on the server?
It's literally impossible because the log cmd thing can't have commands entered to it.
Do I need to code an RPC that executes commands that I want on the server? or is there an easier way
also, I networked profiled on the client (logged in on a dedicated server), do these results seem alright?
Watch the epic deep dive video on networking optimization they explain how you use the network profiler
mmm this one? https://www.youtube.com/watch?v=mT8VUVuk-CY
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
...
thanks let me look
also if anyone knows about this
EDIT: I guess just closign the server with ctrl + c works fine to get the final file
I write the port with my IP address to the "open level" function to connect to the server, but there is no interaction.
Do you have a method to reach another server that you know or see this resource?
pic ur code
Sorry, my english is bad, what do you mean?
take a picture of your code or blueprint graph
Guys, If I'm creating a multiplayer game that can be played on single-player, will the RepNotify functions be called when on single-player as well?
No, you have to call them manually
If you're in c++, in BP they're called with every set
I'm on BP hm
Then it's getting called already
In BP it gets called every time you set a variable both on server and client
So I don't have to worry about calling them even on a single-player instance of the game?
No
Only arrays are iffy, if you use Array.Add(), repnotify won't be called
On server
So you have to call it manually there
np!
hi,
I have an actor that I spawn on the server and is replicated to clients,
and apart from that, it just has some RPCs. no replicated variables. Can I set it to Dormant All and it will still work fine? Also I need it to get deleted for all clients when I delete it on the server.
hey guys, any idea why im getting a bit of lag on my client(peforming the action) screen? everyone else but the person viewing themselves perform the action on the clientside sees it correctly. also is what i circled in red redundant?
u can't do sprint in blueprints
it must be done in cpp because it's part of the movement component
here is how to do it
files download included
thats crazy. so i cant just change the default max walk speed?
i also had a similar issue when i changed the scale of the character to be a giant(just for testing) seemed like it was causing some lag to the person who is performing th action
no. it's not that hard. look at the video and u can just download his files and he has bp functions for it
this is not the same issue, and this is probably possible to do smoothly without cpp
has n1 here tested how many players can "out of the box" unreal server hold without issues?
fortnite has with 100 players
so if you remove all functionality, probably 300+
ye but i think they did some modifications
Really depends on the hardware though.
i am aware
but i was just looking for a ball park figure
There's not really a simple answer IMO, depends on all the features you have / the nature of the game, how well optimised your server is and like just said the hardware you want to run on. And in the end if you plan on actually running dedicated servers you should look at it your self because it's a lot of money down the drain if you buy/rent more expensive hardware then you need.
ye i know, im just trying to get an idea of how many players an "average" setup would be able to support
say a not so complicated shooter like COD on ur average top of the line desktop
do u think it would be able to hold like 64 players?
or maybe 50
also whats the bottle neck exactly? the amount of data the network has to send?
or the processing power nescessary for the server?
I mean Fortnite and PUBG can run a hundred at once in a pretty big map, so it's possible. I just don't know what hardware they run and how optimised it is.
could some you get away with it if you slowed down tick rate for example=
You can definitely squeeze some performance out of that, which isn't ideal for a PvP shooter though if we're talking COD like.
ye but form what i know the netcode for fortnite is modified
battlefield does 64 players i think
so it should be doable
Battlefield doesn't use Unreal though.
Regardless of in specific the player count, dedicated servers them selves are complex and very pricey. You need to maintain them which people really underestimate if you ask me. You need to do a lot of work to even get it to work most of the time (or pay even more to do stuff) for things like matchmaking, inventory systems, crossplay, shops and whatever else your game may have.
May I ask if you're doing this alone or with a team?
If you're alone I would honestly say it's going to be extremely difficult. If you have a team you could do it, but that likely assumes you have people that know more about it already.
i was just asking out of curiosity
im doing something with servers but the players per server is going to be 6 players max so its not an issue
i am going to be doing dedicated dynamic servers tho
but i am taking it slow
im coding a matchmaking server now going good so far
hopefully i will be able to run some servers for ranked matchmaking on a spare laptop that i have
A variable set to replicate will ALWAYS replicate even if has not been changed on a RPC?
Replicated variables will only replicate their value to Clients if the value has changed on the Server.
Read the Compendium that is pinned in this channel.
Doing sprint like that will never work perfectly smooth
I'm slowly reading it, just wanted some confirmation to try some things, tysm though!
Quickly jumped to the replication part, so from what I understood, the best way of changing a replicated variable to be replicated, is doing it on a RPC, since RepNotify does things AFTER the variable has been changed, and does not change it on the server and then do the stuff, correct?
Replication doesn't require RPCs. Replication only requires that the variable is set on the server.
Take the following examples on a replicated actor.
The begin play will fire on the server, and set the "ReplicatedBoolean" to true. This variable will replicate to clients without requiring an RPC.
The OnActorOverlap will set the "SomethingIsOverlapping" boolean to true. This variable will replicate to clients without requiring an RPC.
The OnActorEndOverlap will set the "SomethingIsOverlapping" boolean to false only if there is no other overlapping actors. Again, no RPC required.
All 3 of these events can trigger on the server and the client, but the "Has Authority" forces the next bits of code only to run on the server.
There is no "best" way to set a replicated variable - there's only one way to properly do it and that's by setting it while running on the server.
RepNotifys signal that the variable was replicated, meaning you can then do something because it was replicated, like update UI or change the state of something.
Variable replication is from server to clients, always.
The only way to get data from client to server is an RPC (Run on Server Event)
If you want to do soemthing and have it reflect everywhere, you:
Client
Run On server Event passing data
Server
set variables
Everywhere
Repnotify fires
Hello, are DedicatedServers on UE4 supposed to have a PlayerController?
Thank you for these great examples, I got to understand it better now thanks to you guys
I'll keep on learning as much as I can, tysm!!!
yes
There should be 1 playercontroller per player
an empty dedicated server doesn't have any hanging around I'm pretty sure.
Hi I am wanting to add a spawn effect for when a player joins / leaves the session like a dissolve effect how would I go about doing this much thanks.
If I'm overriding a multicast... it's still a multicast, right? Or am I gonna need a new event
I don't have the answer but you could make you multicast call an OnDeathFX event which you can override instead
Does anyone have some educational resources for proper replication in UE one can look into or some examples of it?
I watched some youtube tutorials but they are either not teaching proper practices or doing bare minimum & not explaining in enough detail so one can understand it & apply to it's own code.
These tutorials only made me confused so anything to help me with the proper thought process is more than welcome.
Check the compendium in pins. It gives you some examples but focuses more on explaining how replication works. From there you can apply it to your game. Some common sense goes a long way, such as "don't trust the client" and don't make them an authority of anything. If they send data to the server, validate it the best you can. If the client needs to do anything on the server, RPC from the client to the server to do it
Will do, thank you for the help!
is there a way to have a client temporarily leave the session but store the session result somewhere as a persistent variable and travel to a new single player map and then once done, use the saved session result variable to rejoin the same session again assuming its valid?
What problem does this solve?
Pretty sure this could work. I haven't looked into it but you join a session from a handle
Or be more specific on what you don't know how to do..
Hello can someone help me about UE5 dedicate server online?
I have a dedicate server working good, i want to know if i can or if its possible create a session inside of the thedicate server, to made matchmaking 1v1 etc...
thanks
So it doesn't have a local one, PCs just for people connected to it
so i'm helping someone who is making a multiplayer game that consists of mini side games that are launched client side only and are themselves only intended to be single player, they were wanting to possibly have separate maps for the mini games, and trying to see what the best way to accomplish this (they dont necessarily have to be separate maps, anyway that would be most efficient)
Stephan's multiplayer shooter course on udemy is golden
Hello everyone,
I have a RepNotify in my weapon blueprint which should trigger an event in the character blueprint.
This variable replicates as "inital only" as it should only be triggered when a player enters the relevant distance.
Despite the fact that my character has a higher Net Prioity he is not reachable with GetOwner as soon as this value is transmitted.
Therefore I let the function repeat every tick like in the picture below until the character is valid.
But now I wonder If I can optimize the whole thing, so that the character is always valid at the first call. Is that possible?
Hi all, trying to debug a crash when I run a separate server in a separate process. The window closes immediately. Does anyone know where the editor puts those logs?
I don't have any problems when I run under one process, which is also weird.
Should be in saved/logs If you're running editor from IDE you should see any errors in the output as well
After a while of going crazy, I'm going to ask two questions:
-
Does anyone know about any approach to a load screen that works in multiplayer that doesn't use the video player? Specifically I'm looking for something that allows chat and such during load.
-
I had one idea for this and this was to have an empty uworld and use level streaming to prepare the levels but I can't find any information on managing a secondary uworld instance (doesn't even really need to do much, just exist as a secondary place for clients to exist in). More or less as long as a player can join the session into the empty world and send+ receive rpcs this would be all I need.
For both cases I'm capable of writing any supporting c++ logic, just not having any luck figuring out how to manage a secondary world for question 2.
For why I'm avoiding the video player: it seems like it only works with slate and I couldn't get it to work in editor for testing.
where can i find resources about serializing raw classes?
im wrapping a raw class in ustruct to pass it into a rpc, however the server receives a null, kinda expectedly..
You can do client side only stuff on a normal server, just don't replicate the state of the mini game to other clients. If you isolate the sections of the level for the mini game you can teleport the player to the area they need to be in
hey guys, im trying to spawn a widget on all player screens on begin play, but for some reason its generating an error, images are attached, and thanks in advance for any help!
you need to create the widgets by calling the event on every owning client, rather than the multicast
like this? also doesnt work
run on owning client also does not work
Is this on a dedicated server or on a listen server?
dedicated
Ok. You don't want to create widgets on begin play on characters. You run into problems as every character in a game can trigger and retrigger the widget to be created. So if you have 2 players, each player will run that same code twice. Not only that, but the dedicated server itself cannot have widgets, so it can cause the error there as well.
You're better off creating in the player controller's begin play, and use Has Authority (Remote) > so that only the clients create it for themselves.
ah, ok, this works, but I also have an event in my character to change text in the widget, so how can I pass a reference to the widget?
Ideally you'd have your UI bind to an event dispatcher in the character.
Your UI can also "get" the "Owning Player Pawn" when needed.
can you explain to me how I would do this? im not too familiar with event dispatchers
Create an event dispatcher in your character. The spot to do so is usually under the variables.
You can also add inputs into the dispatcher in case you want to pass data through it.
In your ui, you'd have to cast to your character class and then bind to the event.
Then you just call your event dispatcher in your character whenever you want to.
works like a charm! thanks a lot!
one more, so I have this pickup, and its supposed to chase the player when the player overlaps with a sphere collision, until it hits the player than destroys itself, and it works ok on the client, but not on the other clients (server i assume). When the coin chases on the client, it just instantly disappears for the others. Can anyone help me understand why this happens? Im not so good at networking
here is a video outlining the issue
any help would be much appreciated
Hi! how do you all deal with Monster Spawners-Item Drops, etc?
I'm spawning one Actor for each, but having around 100 (spawners) and probably hundreds of (Items) dropped at the same time means hundreds of actors only for that. I think it's insane, does anyone know of a better way?
Not sure why (have been testing for hours), even though I filter the player class and the player actor itself, if I hit enemies or another players, my character loses health, which doesn't make any sense
It works completely fine on single-player, but on multiplayer it happens on the server/host and on client as well
Also for some reason, when I restore health on characters, on server it works but on client it doesn't, but if I'm playing only with clients, it works on both (I'm using two games to test)
This should be Running on server (if it's not already)
How are you subtracting heal?
If you don't have a OnRep for the health variable, you should do a MultiCast so the Clients are aware of the changes, if not. the server will change but the clients will never know about it.
The event is being called on the server, so shouldn't the health which is set inside that function replicate for the clients automatically?
It will only replicate if the health variable is set to replicate and the owner is set to replicate also.
The player attacks, the server verifies what is inside of the collision, filters the player itself and other players as well, then it proceeds to decrease the health, this is all being called on the server hmm
Yep, both health and the actors, components as well
how are you decreasing health?
I made a "Remove Health" event that decreases (subtract node) on the given amount, also runs on the server hm
Show me on this graph the heal subtraction please
or where ever it's called, I want to see what actor you are passing as the target
Oh, I already turned the computer off, was heading to bed, I'll send you screenshots when I get back from work D:
no problem, feel free to quote tomorrow.
I'm giving the array element as target
btw, without knowing the system I would put a check on that for each loop and see what actors it's gathering (to make sure your filters are working okey).
I made sure to print it once, the print would show the enemy but the health was being subtracted on the player lol
I'm almost sure is something network related that is causing the issue, as it works fine on singleplayer
btw2, if you want to remove yourself from the overlap check, add yourself to the "Actors to ignore" List.
I did it once, just changed when trying to fix this weird situation
at the top of my head, i can think that maybe you are using some "Get player character / Get character controller"(0) on the server at some point, not sure.
Thank you for taking your time to help me btw, sorry I'm away afk now
Your spawners should likely only spawn anything if there is a player nearby. If you want to further optimize it, then you'd probably also handle removing actors that were spawned but there is no longer any players nearby. If you have some form of respawn timer then you'd also want to incorporate it -> if the timer is up but no player is nearby, don't spawn anything and only spawn when a player comes into range. If the timer is up, and there is a player nearby, spawn it.
As far as drops go, they should have a lifetime given to them so that they only exist for so long.
You probably don't want to use RPCs for any of this. Everything should be handled on the server VIA a replicated actor. The actor should only react to overlapping on the server - use a Has Authority (Authority)> node to restrict actions of the overlaps on the server. The server can make the item move on its own without needing a client to send an RPC to the server telling it to do so. Similarly since it is a replicated actor, its movement would be replicated automatically without having to do a Multicast. Finally, destruction of the actor only needs to happen on the server for it to be destroyed for everyone.
Last thing, rather than using a delay to perform the move, just use tick and a gate. Movement is one of those things where it's fine to use tick.
is World Partition client/server aware? aka can the server tell when a given actor is not loaded / relevant to the client?
How can I run a dedicated server on Android ?
Do i have to package the server for android separately ??
I don't have the answer but usually you would not do this. Each Android device would be a client and the dedicated server would be running on actual dedicated hardware, like aws or a vps or something.
Is it necessary to package games with source engine
I have 2 pc. And i package the server with 1 and apk with another
Not sure what this means, but I'm assuming you are talking about the engine source, and not the source engine that half life and Co run on
You should end up with a server build for the server. Never built for mobile so I can't help you with that
Okay π
If you have more questions about packaging you should check out #packaging . This channel is more for working multiplayer stuff
What is IsLocallyControlled()
Local role is autonomous proxy or something different
bump
bool APawn::IsLocallyControlled() const
{
return ( Controller && Controller->IsLocalController() );
}
bool AController::IsLocalController() const
{
const ENetMode NetMode = GetNetMode();
if (NetMode == NM_Standalone)
{
// Not networked.
return true;
}
if (NetMode == NM_Client && GetLocalRole() == ROLE_AutonomousProxy)
{
// Networked client in control.
return true;
}
if (GetRemoteRole() != ROLE_AutonomousProxy && GetLocalRole() == ROLE_Authority)
{
// Local authority in control.
return true;
}
return false;
}
So this give true when it is on standalone
Or client controlled pc
Or all client on server
Am i correct ??
When Standalone
On client controller on the client
On listen server's controller on the Server
I want to do like when a player overlap actor sphere , then a widget come only on that person which overlap it
So i am thinking that
Remote role = authority || localrole = autonomousproxy
Isnt that work ??
Get the actor that overlapped, check if locally controlled, if so, display the widget.
Same with the reverse on end overlap, check if locally controlled, if so, remove the widget.
Overlapped actor should be replicated ??
It doesn't specifically have to be. If it isn't, other actors can still trigger events on the clients. If it's only spawned on the server, then you'd have to tell the clients that they've overlapped through an RPC or an onrep variable of some kind.
Okk let me try this , btw thanks for helping
I just replicate and show widget only in IsLocallyControlled and it worked but when i attach actor to component , it will not work
I guess i have to call rep notify so that all clients know that someone pick actor
Can I change the map a session is in
like literally change the session map
while keeping the session active and players connected ?
You would do a seamless server travel to the next map
hello people. i'm having issue switching pawn for the client, the logic works fine on the server side;
When the client interact with an actor, a server RPC is issued spawning the new pawn passing the reference to the controller who asked for the pawn to be created, i then try to possess it but the client will just spawn the paen but will not be able to control it.
Once i created the pawn trough the server RPC should i do some Client RPC to control it? what am i missing? thanks for the answer
something lie this if cpp:
if(!ensure(World != nullptr)) return;
World->ServerTravel("/Game/Maps/IslandMap?listen");```
this should happen on the host only and will bring all client with him
Hi, im a beginer with ue5. I have a Dedicated-Server setup. When run 2 players in the viewport and connect to the server the second client that i connect to the server is getting a black screen. When i pack the client like the server and run its exe it works well. Anyone knows this issue and can give me a hint?
this is what the second client screen looks like:
Hello guys! I have some questions regarding working on a multiplayer game as a team.
For reference: the game we're thinking of making is an FPS Multiplayer, something like DayZ (dedicated servers, no matchmaking)
When working with a team, does everyone need to have the source engine built?
No, you can and probably should develop with a listen server with regular source control
And then periodically test with the heavier dedi method
Ok. Will the listen server allow us to join from different networks? (Everyone from their home)
That's unrelated to the networking model and mostly a matter of using Steam, any other online platform that does NAT punch for you, or ensuring open ports on whoever hosts
Ok, do you have any documentation on working on a multiplayer game as a team?
I mean - where's the issue? You won't normally work on the same features at the same time so you'd just work locally with two instances on your machine, and then when you want to play with the others, have someone compile the server
"multiplayer as a team" is just "gamedev as a team" except you need to agree on a commit, and find someone playing as listen server or deploy a new dedi
there's no actual difference...
Anyone can help?
Is there anyway to force a listen server to always call itself for on_rep notifies (when a value changes)?
If we take a simple idea - that you update a variable and then want "clients" to react to it, this is what I would like to occur:
void ServerUpdateAmmo()
{
Ammo += 5;
}
void OnRep_Ammo()
{
UpdateAmmoHud();
}
But unless I'm misunderstanding something - I always need to do something like this?
void ServerUpdateAmmo()
{
Ammo += 5;
if (! GetGameInstance()->IsDedicatedServerInstance())
{
UpdateAmmoHud();
}
}
void OnRep_Ammo()
{
UpdateAmmoHud();
}
Is there a way to tell the listen server to treat its own client as something that needs to be handled like any other client?
There is no built in way to tell a listen server to call onrep functions for itself. Instead, you would just call the onrep function manually on the server. Wrap it in a macro or something if it makes your life easier
Just make a setter function
That's actually a more better option
Setter functions is a good idea anyhow, way easier to debug things with setters even though the variable is public
imo
but where am I calling the setter function from? I would still need to handle two pathways though right? ListenServer + Client?
SetAmmo() - I have to call that one in each path?
Sorry, I'm probably missing something obvious - but I still need to call that twice dont i? How does the listenserver client get the HUD update in this example?
void ServerUpdateAmmo()
{
SetAmmo(5);
}
void SetAmmo(NewAmmo)
{
Ammo = NewAmmo;
}
void OnRep_Ammo()
{
UpdateAmmoHud();
}
i'm keen on the idea of using setter functions if its a better habit - i'm just trying to get my head around the 'flow'.
If Ammo is a replicated property and is set to an OnRep, what you've done here should be sufficient.
Only the server needs to use SetAmmo, the property gets updated, when the property replicates, OnRep_Ammo() would fire on the client, which then calls the UpdateAmmoHud().
but it wont fire an OnRep on the listenserver's own client though right? which means the localclient is not updating, only the remote clients?
Right... So then in your SetAmmo function, since it's only running on the server, you can forcibly call OnRep_Ammo().
yeah - it just feels... weird that I need to do that for basically all my functions.
I dont understand why we cant have the listen server treat its own client like all clients, because to me that would greatly simplify the coding? It feels really strange that we need to handle two different scenarios - like when would you not want your local client to match a remote client getting the same type of data...
Anyway - yeah, I'll just use setters and call on-rep itself I guess...
I do have all of that, my maps are like in path of exile, where you open, enter, and leave.
The spawners have a trigger sphere of collision so they spawn only when the player gets nearby and destroy themself after fully spawning everything.
But I was thinking if maybe there's a way to not use soo much actors for the spawners and drops
im having a bit of an issue with replication. I made a coin that will follow the player when the player gets close enough to it, until it reaches the player, and is then destroyed and adds a score to the player. This functions well, however it does not work when spawning it. Im trying to make a chest actor that spawns a coin, and shown below is the spawning function. The coin is spawned only on the one client which interacts with it (interacting is done through a bpi, where when the player hits E, it sends the event to all chests overlapping the player (they have a box overlap), and the drop event is called). The drop event is not replicated, and simply says where the coin should spawn, which is then passed to the next event, which is a multicast, and actually spawns the coin, which has replicates ticked. Ive also attached a video showing this. any help would be much appreciated
Picture what calls the "Drop" event
keep in mind that Multicast events have to be called from the Server
(so if u want to call a multicast from the client, u need to first have a server event, and then a multicast event from that)
and no I did not read the wall of text
character calls this bpi to whatever its overlapping, chest calls drop function (drop function is in the component)
yea so just like I said above.
changing the drop event to server causes nothing to happen
did u print log and make sure it executes on the server?
maybe ur actor isn't replicated correctly
print log doesnt execute
pic ur replication vars in the bp
i have no replicated vars
on component
show on actor
on coin
its also set in the coins component for good measure
coin replicates fine
however, when it is spawned from the chest, it does not seem to be replicated
so show how u spawn it from the chest and the chest's replication vars
how its spawned from chest ^
chest component
chest
coin is spawned from the chest component
FYI there is no reason for the component to have replication on if replicate movement on the actor is off and if you have no replicated variables in the component
the chest has to be replicated if u want to spawn the coin from it
or u can call an event on another actor to spawn the coin
enabling replicates on the chest has no effect
(an actor which is replicated)
^
it does a few other things rather than just spawn the drop
What's the best way to block new people from joining the session after a certain point? Say a couple minutes into a match-in-progress, what setting can I change at that point to stop new players from joining?
I'm trying to join to a session, is working when I use the Console Command, but not through blueprints.
I'm having this message, any ideas?
TravelFailure: LoadMapFailure, Reason for Failure: 'Failed to load package '/Game/_CustomServer/UEDPIE_0_Mapa''. Shutting down PIE.
?
show how it works and show how it doesn't work
code
also did u try googling that err
yes
when I execute the command manually directly in the console is working
when I execute these commands is not
the idea is to do it automatically for the players
that's what I did, and I have this message
I did it, a totally new level
and it still won't work ?
2
is if (GetOwnerRole() == ROLE_Authority) the same like switch has authority in bp ?
not yet
yes, i also tried this
try in packaged
Not entirely.
FORCEINLINE_DEBUGGABLE bool AActor::HasAuthority() const
{
return (GetLocalRole() == ROLE_Authority);
}
Your coin should likely be a replicated actor if you want it to spawn on all clients and for there to be one single referenced coin. Using a multicast will make it so every client and the server spawns its own copy of the coin, but none of it is replicated.
What you probably want is:
- Make sure your chest is marked as a replicated actor.
- Have your interaction input call an RPC to the server.
- While running on the server, get your overlapping actors and loop through them and call your "Drop" interface.
- The drop interface on your chest can then spawn actor from class - make sure that any actor you are spawning is a replicated actor so all players can see it.
Im not quite sure what an RPC is, is that just an event that replicates to server?
@sinful tree but i can use it safe or better to use your method?
i call it inside of Component
RPC = Remote Procedure Call. When you mark an event as "Run On Server", "Run On Owning Client" or "Multicast" you're marking that event as an RPC.
"Run On Server" RPCs can be called while on the server itself, but is meant to be called from a client to ask the server to execute something. In order for this to work, the client must own the actor the RPC is being called on. So for example, a client could call a "Run On Server" event on their player controller or character as they own those actors, but they couldn't call it on say, an NPC or a spawned actor unless that actor was marked as owned by that specific player.
"Run On Owning Client" RPCs will only work if there is an owning player of the actor you're trying to RPC on.
Multicast RPCs can only be called while you're already running on the server, and will only run on clients where that actor exists. It also will run on the server itself. This is a means of having multiple clients react to something that is like a fire once and forget, like visual or sound effects.
this works, kind of. i marked this image with a check mark on the clients it works on, and an x on the one it doesnt (client 0 it seems) why isnt this replicated on 0?
What I showed was the contents of the "Has Authority" macro. Within a component you can't directly call it since components are not actors - you'd have to get the owner of the component and check its authority.
What part of it works / doesn't work?
but how can i have 2 poeple play the same mini game at the same time but separately, its working when 2 want to play the same mini game together but not without seeing each other, would like the to have 2 instances of the same mini game but not at all be aware of the others (the players i mean)
sorry for the late response, had to take care of smth, but its a little difficult to put into words so i made this video outlining it:
Doesn't look like a replication issue. That looks like an issue with your pickup logic.
when 2 of them are spawned, and none of them are replicated to client 0? when sitting on the ground normally everything works fine, but spawning them in seems to have issues
also do you know what this means? LogScript: Warning: FLatentActionManager::ProcessLatentActions: CallbackTarget is None.
that error arises everytime client 0 hits e
you may also notice that client 0 also gets a coin added even when it looks like no coins are going to him, and the coins are going to the clients
No idea, but again, this is likely an an issue with the chase/pickup logic you've made so far, and likely has nothing to do with replication and everything to do with how your items are behaving once spawned.
How do I give a client permission to have inputs on an actor in the level?, Would I need to unpossess his character first?
What are you trying to do?
Basically be able to press key to do something on an actor in the level, I've currently got enable input on the actor and disable input for the character but neither things happen
It's a puzzle
I feel like the input actions are not working on the actor as I still have control over my character, I guess un-possessing is the only way to disable input of a character?
Explain more. Is it more like the character is doing an interaction or the player themselves?
What's the actual game mechanic
So if the player clicks on the actor, and then changes camera to said actor, and is then able to do things on that actor with input actions
Like Press Up, Set rotation +10 degrees
The input sides are not working
I'd just make it a pawn and possess maybe. Depends.
You could also do this
Press Key -> Set MyPuzzleActor -> Set view target to it
Other inputs
Input -> if MyPuzzleActor.IsValid -> RPC -> DoThing
You're basically making a shitty temporary possession mechanic
Or you can have server set ownership and enable input then it should do things too. Really depends on the specifics
I'll try possessing, my only concern was unposessing from a input action, ig I just call from server to unpossess should be fine
Don't unpossess, just possess back your old character.
This would be something you do in PlayerController
Input -> Logic -> RPC to server -> Possess Thing or OldCharacter or whatever
Ah, good idea, thanks buddy
However you end up doing it, remember that you can only call RPCs (influence ANYTHING on the server) through actors that you own. You automagically own your possessed pawn, and you can also own other actors if the server sets the ownership to you.
That's what I was missing, so technically you can enable input but you have to own it first
Possessing would work in my case though as I want to lose control of the player and have full control over actor
or pawn should i say
Yeah that's a pretty good use case for possession
Thanks again buddy I'll give it a shot, the code is all done just need to figure this part out lol
Does the movement work in multiplayer?
If not then the code is just started lol
I haven't fully tested it in multiplayer, but I've used similar fundamentals to my other blueprints, only the possession side is different
I'm confident
But then again who knows, it's definitely 99% trial and error 1% logic lol
Does we have to replicate collision of actor also ??
Is it really necessary to build the project as "development server" to get the server build working?
The connection is working in the editor, but not in the build.
It works, thanks man, I've also got a universal possess of char/pawn via player controller now too should save me hassle in the future
I'm having problems trying to start a camera shake with owning client only. The way this event is called is something like:
Server event > Multicast Event > Owning Client Event (screenshot)
The problem is that the camera shake is being called in all clients, and I don't know why.
It's because you're calling it on a multicast and the "Owning Client Event" will still execute locally on each client.
I feared that to be the case.
Isn't any way to "escape" the multicast for this specific event?
Found the solution.
I did it, but is still not working in the build. I added the maps correctly, but the connection to the server is only working in the editor, for the clients editor and compiled clients are both working
As I said, you need to not replicate any of the mini game state to other players. I don't know enough about what you are doing to give you any more help. Minigame data should be replicated only between the server and the player in the Minigame. In cases where the server doesn't need to know about something, don't tell the server and keep it on the client
Guys, simple question, but wanted to ask to have some confirmation. As the server and clients are each an instance of the game running, every code runs on every game, correct? So for example, if I'm setting VERY IMPORTANT variables, I should do on the server only, right? (For example using Switch Has Authority)
Although, if I set replicated variables on Begin Play or anywhere else, using Switch Has Authority, will these variables be replicated to the clients as they're being set on the server?
Remember that variable replication is server to clients only, so whether or not a client changes some data on there and it doesn't matter. Nobody else sees it
But then if I call an Event that replicates (on mode "Run on Server"), inside Begin Play, will it be called normally on the server?
I remember reading to not use begin play on online games for some reason
Probably because if there are too many things inside BeginPlay on too many actors it can get data expensive?
Is it possible to spawn and posses a non replicated pawn on a client for a client?
Ive tried it through the controller, it still gets spawned at the server side and not posses at the client side.
Is the a way to decouple the client controller from the server somehow?
You can use begin play, you just need to understand how it functions and when it is called.
For example, using Begin Play on a character on clients is sometimes a bad idea as that code can be called multiple times when the character goes out and back into relevancy range. You can't reliably do everything on Begin Play, say for example, you do Begin Play on your player controller on a client and want to get their playerstate, but their playerstate likely hasn't replicated yet.
Setting variables on the server should normally be handled while already running on the server. You really shouldn't need to have the client tell the server to do anything on Begin Play via a "Run On Server" event as Begin Play already runs on the server, so it should run it's own code using the Has Authority (Authority) > path.
hey guys, having a bit of an issue (again). basically i call an interface each time a collision overlaps, with the target being the player, and when the event is called in the player, an event dispatcher is called, which tells a widget to change the score. issue is that the widget doesnt seem to receive the dispatcher event. a print string shows that the player interface event is called properly, (at least on the server), however the widget doesnt seem to receive the dispatch, though it does sometimes catch the dispatch.
this issue is generated (on the server) seemingly each time the dispatcher is called: LogScript: Warning: FLatentActionManager::ProcessLatentActions: CallbackTarget is None.
i find this to be because only client 0 is calling the pickedUp event, why is that
Widget only exists on client
listen server or dedicated?
So where in this logic chain does it get from server to client?
Show the entire chain from overlap to widget update
overlap: box collision is created on begin play, event is binded
interface in character is called, which shoots a event dispatcher
however, ive found that only client 0 is sending the interface, not quite sure why
widget (is supposed to) update text when dispatcher is called
btw widget is made here in the controller
So where are you doing the server/client differences? I see no RPC here. Are you just doing the pickup stuff on client?
adding a print string after the overlap here, any time any character overlaps, only client 0 prints a string
pickup stuff happens here
when the box is overlapped, the pickup actor is destroyed, and the pickup is communicated to the player with an interface
Server or client? because client can't destroy a replicated actor, and server doesn't have the widget
so you need replication somewhere in there
all this is in a component
maybe thats the issue
what should i do?
i mean i do this as well
OK what is this component meant to do?
You're doing a lot of stuff at Begin Play that seems like it can just be set at construction time or just by instance properties
component has no construction script i believe
also this system is supposed to turn an actor into a magnetic pickup
What i mean is why not just have the component replicate by default?
also you're setting the OWNER to replicate, not self
it does
yep
This component could be a subclass of SphereCollider too btw I think
just a spherecollider that does pickup stuff
not sure how to do that, i just spawn a sphere
also id like to point out that the interface fires with actors that are spawned rather than already in the level
ones that are already in the level seem to send their interface to client 0
well consider that the other clients don't exist when the server boots up
but the reference to the player isnt passed at startup
its passed on overlap
client 0 shouldnt be overlapping any or all of the actors on begin play
i believe it has smth to do with this error, and the overlap defaults to client 0 or smth but i have no clue what it means LogScript: Warning: FLatentActionManager::ProcessLatentActions: CallbackTarget is None.
Which node has that error?
not sure, gives no details, but i believe it has smth to do with the overlap here
its generated in the server log
every time an actor overlaps with a pickup already in the level
and again, not all actors, most, but sometimes it will randomly work
First off I'd filter the pickup by Authority
so nothing happens on client machine only
and print OtherActor and see what happens
like this? it seems to return true every overlap, the name is printed correctly in the server log, and for the spawned actors (the ones that work), its printed to all clients
the error is also printed tho for the server (on the non-spawned actors)
i take my previous statement back, just realized the name passed in the log is the pickup actor, not the player, which isnt a target class so it shouldnt be working
however, if i use the false of has authority, it prints the character name, but also says the characters class isnt in target classes (as seen in the branch), which it most definitely is
well actually no, it does pass the branch, the do once node fires, just the destroy actor doesnt seem to work
im guessing its not working because the owner doesnt have authority
thats odd because the owner replicates
If the owner is replicated it'll have authority on server and not have it on client
how can i give it the authority to kill the actor?
i tried an RPC but that didnt do anything
I mean your whole setup seems goofy, I'd start from the earliest parts and make sure it works all the way through the chain
This component sure is doing a lot to its parent actor
yeah it does literally everything, parent is empty
it was working before, and everything seems to be working now except the destroy
which i think is now tied to the authority
Thank you so so much!!!
I'm saving these tips, I really appreciate it.
so ive reversed the effect using a custom event that replicates to the owning client for the interface, now it works most of the time, and only some random times (and always the first time) wont work and generates the message (LogScript: Warning: FLatentActionManager::ProcessLatentActions: CallbackTarget is None.)
so now im pretty much 100% sure the error relates to the interface, but again im not quite sure what causes the error
actually ive learned how to replicate the issue, by running away from the pickup, but not quite sure why it causes an error, especially as the collision follows the pickup
for some reason this doesnt happen to client 0
i have another related question, but i already typed it in the forums, so im just gonna link that rather than type this again (the forums are even harder to get help on): https://forums.unrealengine.com/t/interface-failing/661827
I have a dedicated server and clients have a pawn which has modular mesh parts. I use replicated structs on the playerstate for torso, head, legs, etc. which contains the mesh and material reference. OnRep functions set the mesh and materials appropriately. This has been working fine so far, even under heavy lag. The other day though, I had a client unable to see some of the characters in the lobby and then inside the game map (i copy these mesh/material refs during seamless travel to new playerstate). I see a bunch of these types of errors in the client's log that couldn't see some of the other characters.
...
LogNetPackageMap: Warning: GetObjectFromNetGUID: Attempt to reassign read-only guid. FullNetGUIDPath: [2149]/Game/_Assets/Military/Mesh/Body/SK_Military_Head6
Looking through this discord I see something similar happens when an actor is spawned on the server but the client hasn't loaded the class yet. Would that make sense for what is happening in this context? Like the modular mesh or materials aren't loaded on the client? I have hundreds of possible mesh parts for the character so I don't want to load all of those.
Can I check on the client to make sure the mesh components are loaded correctly and if they aren't, reset the playerstate and hope i get correct values replicated again? What would the right way be to do this?
hi is there a launch parameter to set the server's language?
does anyone know where i would find the documentation on implementing voice chat into my game? just general voice chat, i don't need it to be proximity vc, im using advanced sessions w/ advanced steam sessions in UE5
Is it possible to replicate media files?
like if I want to watch movies together in a multiplayer setting using a local video
Not really something I would recommend. Typical 1080p movie would be several hundred MB and not everyone has a reliable or fast internet connection or data cap. It could take a few minutes to a few hours for this to download. You also wouldn't be looking at replication for this but rather a straight download from the server, or a CDN somewhere. I'd be careful about copyright laws with a CDN though
@plucky prawn Hi, I just want to know if it's possible or not.
I don't think there would be any copyright strike either, it's basically an mp4 player. You can't blame dev for allowing mods in a game
It's possible with a lot of C++ and terrible quality, yes
I see, so not from the get go?
Absolutely not