#multiplayer
1 messages ยท Page 629 of 1
no errors then, either?
nope
and the issue isn't that UMG can't access GameState properly?
this should work?\
GameState is indeed replicated Server to Client and exists on both?
GameState exists everywhere, is replicated
okay that's what I read and that's why I'm trying to have my Lobby widget just update the PlayerCount off the PlayerArray
would there be a reason the GameState is not populating the PlayerArray?
okay so Server is reporting PlayerArray growing
however, Clients are still seeing 0
what would be the proper function call in a UMG update to get the GameState and the PlayerArray properly? Maybe I'm doing something wrong in the UMG to get the data?
GetWorld()->GetGameState<AMyGameStateExample>()->PlayerArray.Num() ?
I think I found a way to stop players from joining when a match is already running. In the documentation it says the GameMode has an event called PreLogin and if I implement it to set an Error message then it will reject the player who is attempting to join the server:
PreLogin
Accepts or rejects a player who is attempting to join the server. Causes the Login function to fail if it sets ErrorMessage to a non-empty string. PreLogin is called before Login, and a significant amount of time may pass before Login is called, especially if the joining player needs to download game content.
Is that a good way to do it? I want to make it so players can only join a server when the server is in a "Lobby" level.
Did you consider that maybe it hasn't had time to replicate just yet ?
I said I tested this with multiple LAN clients.
The ones already logged on get updated again, and they still see 0.
How long after connection are you testing this ?
Full many seconds.
I connect a client. I wait. I connect another. Still 0.
The already connected clients should easily have a GameState to access. And the PlayerArray is still 0, no matter how many other clients I log in.
Server confirms it's growing. Client's UMG, using the above function call chain, still only gets a 0.
he did not ask that
he asked when does the widget get created
if its too early, the player array will be empty
put a delay or timer before accessing the gamestate
It is on a Rep Notify to get updated.
what rep notify?
Even later, after it's already made, the update isn't working.
I'm saying an already connected client, with a widget, who is calling an update to get the PlayerArray is still also seeing 0.
To be clear, put this count check on tick on the client and check the array size. If after 5s it hasn't replicated - either network is completely saturated, or you have disabled replication on the player state (doubt it'd work), or something else is horribly wrong
I'll check that.
(Or you aren't connected at all)
They're definitely connected.
even standalone has one player in that array
That's what I figured.
that array only get populated when the playerstate replicates
I'm just confused why an already connected client is incapable of updating. I'd understand if it was behind and was too fast.
I've encountered that before.
Ugh. Another player state issue then?
are you oversaturating your buffers?
No
how do you know you're not
Is this widget in the world ?
I am really confused at the proper way to use a PlayerState.
The general advice I'm getting is to store data on GameState and PlayerState. But when?
It seems like they are just not there yet when the data needs to get passed.
So does everyone put timers in their code?
You can never assume anything about when objects exist on the client
Timers don't cut it
Simply assume objects may not exist yet
I'm really confused how to properly update a UI then.
I just want the UI to get that info.
"if game state not there, then don't show the UI and stay in loading screen"
Is GameState the one big class I should wait for?
When is the best time to actually make the widget call?
There isn't going to be one
Lol
It might take 0.1s or 10s
I am very confused at best practices then.
It's simple
Never assume anything about time
Assume your game state will replicate 10s after the map loads
I put in "infinite until" loops in Blueprints, but that just seems like bad programming?
Can't do that obviously, you would also block replication.
Your UI just need to be comfortable with the data not existing, or the UI needs to stay hidden until the data is there
Okay
For what it's worth I have my entire game hidden until I have the player pawn, player state, various systems completely available on client with validated data
The wait time also allows for textures to load a bit
I suggest doing that
Okay t hanks
Hello, I have a question about when to use the Server arguement on UFUNCTION
Don't know if this belongs here or cpp tho :p
I have a little example in case, pretty new to C++ Networking so any advice is welcome โค๏ธ
void UMetabolism::SetHealth_Implementation(float Amount)
{
Health = FMath::Clamp(Amount, 0.f, GetHealthMax());
if (Health == 0.f)
{
HandleDeath();
}
}
void UMetabolism::SetIsAlive_Implementation(bool IsAlive)
{
bAlive = IsAlive;
}
void UMetabolism::HandleDeath_Implementation()
{
SetIsAlive(false);
}
In this case all 3 Functions are run on Server, what I'm wondering is if i call HandleDeath from Server, will SetIsAlive be on Server too if it doesn't have _Implementation?
They will probs be used in BP too if needed separately since they are callable
Is there any set rule to follow regarding this?
So - maybe I'm misunderstanding something. Inside of the rep notify functions, I am adjusting the speed of the character. When not a client - it is being called twice. I have the variable on the skip owner condition, so why would it be called twice? Shouldn't the owner be skipped?
This is affecting it in offline and listen server mode, and only affecting the server.
The logic (as I understand it) -> Press Aim, call ServerAim, set variable on the server and the characters speed. Then it gets replicated to all other clients, except the owner, then set variable locally, call OnRep function, do rest of local stuff (setting up UI)
Again - if I am playing as a client, it works as expected, but not if I'm playing as the server.
Is it possible to package the server in Development build (to have the logs output) and the client in Shipping build ?
Hi, after execute "open /Game/TPtemplate/ThirdPersonBP/Maps/ThirdPersonExampleMap.umap?listen " character is falling. I can't find solution in net, any help ?
are you using world composition?
@lost dune probably no. I just need simple host/join multiplayer for testing maps and I have bind to UI button execute console command. Ofx when I use play button in viewport I can normaly play as client or listen srver.
Anyone know how to send session custom data or how it works?
there's a FOnSessionCustomDataChangedDelegate but I'm not quite sure how it works
basically I want to update session data before the map travel begins once the client has joined the session (e.g. tell the server when a client readies up)
Any reason why I would be getting this error? I am using Spatial OS.
@me if anyone has a solution
@twilit flint have you got a player start?
would it be ok for me to do all my casting inside my PlayerState, and then pass the references to the gamemode?
@lost dune yes, default Playerstate
Player Start not state
sorry, Ofx I have also on map player start. And when i press play form viewport I use it and works well
I've just saw this problem occurs if I changing different level. If i open ThirdPersonExampleMap.umap when I've already loaded this map then is all fine.
Both maps ThirdPersonExampleMap.umap and MainMenu.umap have same world settings ๐ฆ
Hmm i cant find the PreLogin event in GameMode or GameModeBase blueprint class
Hey, sorry if im dragging the chat back
are there any good tutorials on implementing multiplayer
omg, when I use short level name "ThirdPersonExampleMap" is working, with full path "/Game/ThirdPersonBP/Maps/ThirdPersonExampleMap.umap" character is falling :D:D, @lost dune thx for help
@vague parrot have you tried the Multiplayer Shootout example in the Learn tab of the Epic Launcher?
Has anyone implemented a multiplayer RPG inventory system that supports swapping items when you drag and drop an item into a non-empty slot?
I've been working on this but re-written my approach once already now. It seems non-trivial to get all the edge cases right when you have to get the WidgetUI view, plus client and server data fields to all be synced correctly.
In particular, do you save the "grabbed item" as a replicated field?
If you try and keep the "grabbed item" as a variable only on the widget side, you get into a really weird case when you try to swap an item. Since the newly picked up item you swapped the old item with will not have a new spot yet.
Going back to my subject, I created a subclass of GameModeBase and overrode the PreLogin function to set the error message if the UWorld's CurrentLevel's Name does not end with with "_Lobby", but it does not seem to write to the logs where I put UE_LOG so I think it must not be running?
So from widget side it is perfectly sane to put the 1st item in the new slot and "grab" the second item. But I have two items in the same slot until I also pick a new slot for the 2nd item, from a replicated array perspective.
I made it overly complicated for myself too, by doing a jigsaw inventory. For an inventory with consistent item sizes, I could temporarily swap the items. But for jigsaw, you may have dropped a smaller item and picked up a bigger one. So you can't assume it fits in the first item's slot.
@barren patrol sounds like you may need to prevent drop/swap if the new item won't fit, and if no fit can be found then dont pick it up.
yeah, the easy solution is to not allow swaps at all
or are you saying I should try and automatically find a new spot for the 2nd item, and disallow swaps only if it wont fit?
i tried implementing this with just disallowing swaps, it was ok. felt a little clunky.
Yeah IDK I have never done an inventory before. But I think for when you pick an item up if it is trying to find a spot for it automatically like when you loot in WoW then if client side fails jigsaw test on all positions then it can decide not to ask the server to do it either and then if it succeeds i think the server should run the same fit test on all positions and if it fails then the change wont happen and the replication would correct the client view of the inventory back to before they tried to pick up
Ok you are right, I just tested this in Diablo 3. It will automatically find a spot for the 2nd item, and fail with "Not enough inventory space to complete this operation" error if it can't find a spot.
I could easily mask the swap on the client side by automatically grabbing the item instead, but if the drag is cancelled then throw it in that default spot. And fail the operation if there is no available spot.
Thanks for helping me think through that one ๐
Thank you
Hi Peeps
Question about HasAuthority
If I have 3 components that tick on my actor
Do I have to check if I have authority over each?
I assumed by default it would just run on the client whos using that actor?
But then AI actors and their components who I just need to do an override on my actor ticking like
AIActor::Tick()
{
if(!HasAuthority())
return
Super::Tick()
// my logic here
}
Type of approach?
acceleratxr , otherwise playfab imo
I'm pulling my hair out over this. I'm trying to have the client run a function on the server to deal damage.
Client does line traces and calls an RPC with Run on Server replication. This then calls a multi-cast RPC that deals the damage. I have debugged the game and have seen that the Run on Server RPC IS being executed from the client side (IE - in BP, the execution wire is highlighting). However, that is where it is stopping and I can't figure out why. So, the function doesn't actually get ran on the server.
When the client hits the character - nothing happens. Even though the execution path (up to the Was Hit RPC) is highlighted
(Sidenote - I know the names suck, I was just getting some stuff working. Don't care about interfaces and all that right now either)
as much as I hate doing networking in BP, how did you verify that it's being called on a client?
are you in "play as client" mode in the editor? the first player on a listen server is the server
Debugging mode. Listen server and I am playing as the client, not as the server.
these are 2 different options so please be specific
When you select to play as listen server and play as 2 people, it spawns a server window and a client window
there's standalone, listen server, and "play as client" (dedicated server mode)
I am playing in the client window
so in the BP debugger, you selected the client's world?
Yes
There is a dropdown that shows:
BP_Hero (Server)
BP_Hero1 (Server) <--- this is actually the client, but on the server
BP_Hero (Client) <---- this is the client, but on the client (so what you play as)
BP_Hero1 (Client)
I would strongly recommend play as client over listen server mode for narrowing this down
The same issue exists. For w/e reason, I can't have the client tell the server to run the function.
because the client doesn't own the actor?
Client doesn't own the Hero character? Doesn't that get set automatically upon spawning via the network spawn actor?
well if the owner is something that the can be related back to a player (pawn, controller, etc)
then you should be able to use server RPCs
the output log will tell you if there's an ownership problem
Oh my jeebus. The Enemy has no owner. What in sam hell
What could cause the server to not claim ownership of the AI when spawned?
IE - it is pre-placed in the world
well you need to SetOwner it (or set the owner at construction time)
Shouldn't the server own the AI? If so, how does it work with pre-placed AI?
It's the latter part that is a loss on me. Shouldn't the server automatically assign ownership to itself?
Huh? You were asking about a client calling a server RPC
The client calling it would need net ownership in order for that to work at all
Hot diggity dog. I worked it out. Thanks dude. Crash course on ownership. I get it now. Actor needs to know the owner so it can route the RPC and networking stuff properly.
I was screwing up because I was trying to call the method on the enemy itself. What I ended up doing was, if it was a hit - call a server RPC on the player that then calls the damage function on the server.
I was reading the (if owning client) incorrectly. Early AM coding. Need to go to bed.
Yeah, you can't call the RPC on the Enemy :P
At least not by default I guess
Also not sure if Pawns/Characters even allow RPCs on BeginPlay, even if you pass in the Owner.
Think they need to be possessed first. But that I'm not sure of. Epic sometimes does some weird things that don't follow their usual rules
Hi, i was wondering. EOS provide a join friend or make it a group. But it's not the same way as session. Why do we need to forcefully join the map. And not getting just the infos of the session itself ?
hello, how i can get the player index from the pawn class ?
@woeful lantern Very few things require the player index in multiplayer. What are you trying to do?
i need it for this node "Get Player Controller"
Generally you won't use that for anything server side. On a client, only PlayerController0 ever exists. Which makes it okay to use GetPlayerControler0 for UI stuff on a client or a Listenserver. You should never be using that call in server code though. Even on a listenserver, in server code, you rely on abstract references. Do you want to do something to all player's player controllers? GetGameState->GetPlayersArray->GetPawnPrivate->GetController->CastToPlayerControllerClass
If you want to do something to a specific player controller, the code should be done in a way that it doesn't rely on numbers, but on the logic flow.
i also need it for this:
That probably shouldn't be replicated. Clients should just set that themselves, probably based on the Pawn they've possessed if you have different pitch min/maxes. Server can't really enforce that. Players can hack around it since it exists on their client.
to set it, i need "get player camera manager", but i need a player index for it
there is no way to get it ?
from the controller
or the pawn
Why would you make the server set this for clients though?
Would be much easier in C++ by overriding an onrep. I wonder if ViewTarget stuff would work for that. Haven't tested those functions myself. Not certain if those fire on possession. But the point would be to just find an event that runs when that client possesses a pawn, and then get the local view manager to set it's max/min values.
What you're doing won't really work anyhow unless you're using local coop.
CameraManager only exists once per local controller if I recall correctly. So putting anything but zero should only work on local coop. Listenservers even only have one camera manager, I don't believe it's replicated.
So, making the server try to handle it won't work without sending RPCs back through the client's controller to make them affect their own camera manager, since server has no authority over their camera manager. But the usage shouldn't really require networking. Some form of pitch min/max based on the view target should be fine.
@woeful lantern make a custom Player Camera Managaer BP
set those values, and tell your player controller to use
also you can access PlayerCamera manager via controller
those statics are bad news for multiplayer.
Yeah - it just wasn't registering in my brain what was actually happening. But I've learned so much be doing this little mini-project. Glad it is in BP for the time being - helps visualize the flow. I can already see how I can take this stuff to my C++ game and apply it. Thanks for your compendium btw. I only have one other issue that I haven't been able to solve thus far related to networking. Just doing a work around about it for the time being.
Eventually I'll move into map travel and player state and all that jazz. But not yet.
Hey guys! Sorry for bumping but I have this very strange issue.
Networking isn't working anymore in my project. If I play in editor (listen server, 2 players), the client take a lot of time to load and after it finally does, there is a very big lag.
This started happening after I've updated my project from 4.20 to 4.25.
Everything was fine in 4.20, the networking was working smoothly and now it broke for this specific project (I tried to make an empty project and some rpcs for testing and they were working).
I have no idea what is going on.
So right now I am running 4.25.4. I will give you a brief description of the things I've done after the update. I fixed the includes and switched every single "Role" with "GetLocalRole()". I have deleted .vs, Binaries, Intermediate, Saved and the *.SLN file and regenerated them. That's about it.
Here is a video of the issue (4.25.4): https://youtu.be/0DOKUKvdpIU
Here is a video from a year ago when I was running 4.20.2 or .3: https://youtu.be/r6KEINFC9bM (everything was fine)
In the first video I don't have a shotgun in my hands, but I have tried adding a weapon and the problem persist (as expected). If any of you have any idea what is going on, please tell me.
This started happening after I've updated my project from 4.20 to 4.25.
Everything was fine in 4.20, the networking was working smoothly and now it broke for this specific project (I tried to make an empty project and some rpcs for testing and they were working). I have no idea what is going on.
How do I set the speed for all the clients and not just the server, for this projectile I'm spawning with a variable for initial speed? (dedicated server)
construction script is not called when an actor is spawned iirc
oh
thats pre-placed nvm
but you want to set the speed at beginplay
right. The server is spawning a replicated object
ah good. I almost said something very wrong. The construction script does actually run on all clients. So you're right. I need to replicate the variable
replicating the vars didn't work :S
I tried on both despite what the screenshots say
i know a way, where you spawn the projectiles on multicast instead and have the actor NOT replicated. But something tells me, it's better to just create the actor on the server and have it be replicated
How do I set the initial speed to be set on the clients too?
If a listen server is hosting a game and I want to allow them to change game settings before switching to the main game, i would use the game instance right? Slightly confused as I thought the game instance wasnt replicated
what does replication have to do with it?
does it not?
How to destroy the session to server?
the node destroy session dosent work
it fails
i put in get player controller
Good news: I got my C++ override of PreLogin to reject connections if the server is not in a level whose name ends in "_Lobby". The trick was that I had to NOT call Super or it would approve the login anyway regardless of there being an ErrorMessage set, and furthermore Super would override the ErrorMessage. So i had to override without Super.
The better way to do it is to just call Super::PreLogin after you do your checks (and don't call it if you fail the login)
Alright moving this here
My point from #cpp - you only need the UE4 Steam net driver if you are using Steam for matchmaking
Apparently it's not even needed
it's only needed if you use the p2p connections
We're talking the regular Steam driver, not the Steam socket net driver, right ?
Lorash was saying - "just that even if you ship drm-free you can't use this without the client" but I fail to see how your DRM-free Steam game that uses the UE4 Steam net driver, could also work without the Steam client
The net driver is actually user-changeable AFAIK
But if you have that net driver you're also using Steam itself, so how's that for lock-in @twin juniper ?
you wouldn't, you'd use something like the null OSS for that
unless you have some code to hotswap it depending on if it's launched by steam or not
But it's not a lock-in, though - users can actually fall back to NULL
That's not really the reason though because it takes explicit effort in UE4 to make your game Steam only
it does happen though, when people use those steam plugins from the marketplace (ughh)
that's why the OSS abstraction exists
But there is nothing to implement
The switching is built-in
I know my game has Steam as OSS but I don't have Steam open while working and so I work with NULL
I didn't write that
It's literally an engine feature
The only way to force Steam is to actually write Steam specific code and that's not negligence, that's explicit lockin
In any case the Steam net driver is entirely unrelated to this
It's user-switchable and not even mandatory for Steam apparently
Well you were talking about how Steam sockets would create an accidental lock-in, but that isn't true, the sockets in UE4 are always user-switchable
You're not getting my point here
I'm not saying games don't have Steam lockin
I'm saying UE4 games don't have Steam sockets forcing you to use Steam
The rest of the game might assume Steam
The sockets are user-switchable
And, AFAIK, the net driver will downgrade to default in UE4 without Steam (the OSS certainly does)
Alright so I'll leave it to this : Steam sockets in UE4 can never cause a game to accidentally lock users into the Steam client
UE4 games might certainly get your Steam avatar at launch and then crash because it's actually the NULL OSS running, sure
if I were to want to be able to let players download the dedicated server and have there server displayed on the server list this is where I am getting lost, anyone have any info for this?
You'd put the dedicated server up on Steam as an alternate download or put it up on your website ; and the setup for players would be similar to the setup for regular hosting
Should be pretty straightforward
Not saying how they can download it
I am saying how to make the dedicated server broadcast to a server list
Well, that depends on your online service
If you use Steam, that's handled for you
I suspect EOS and GOG have similar features
If you use Steam, that's handled for you
I suspect EOS and GOG have similar features
steam makes it easy, you will have to ask them to add the dedicated server app ID to the complementary package so anyone can download it
I would like to go down the route of steam but every tut I have seen, it seems like no one can figure out how to get the server name changed from a bunch of digits
? it's a separate app that you name
plus steamcmd works on app IDs
GOG does have an online service with an UE4 OSS
I am referring to the steam server list, when the session is created on the actual steam list it shows the name as a bunch of digits. Its like a random generated id
well name it?
4Head
If it were only that simple hahah
With dedicated servers its different then when its just a p2p server
UE4 doesn't have p2p servers.
(UE4 also has listen server btw if you want to avoid all that)
how many times in the last week I had to repeat that p2p is not a thing with UE4 is getting highly annoying ๐
You must be new here
maybe it'll be a thing if you believe hard enough
(or if you write your own networking layer, have fun!)
make your game play-by-email - now you don't need netcode at all!
in fact I don't visit this channel often ๐
well it is, the steamworks API call is SetServerName under ISteamGameServer
To be fair a turn-based game works perfectly fine with listen server, you can even make each client very highly autonomous on top of it and only use the UE4 networking to pass data along
Advanced sessions is inside of UE4 isn't it?
It's a plugin
advanced sessions is a ue4 plugin
I am aware, maybe p2p isnt the right term
what you are referring to is a listen server not p2p, where the server is at the same time one of the players
but we had to modify the online subsystem to readily expose it
P2P implies that clients can talk to each other. In UE4 networking, clients have zero contact with one another. A client can only ever talk to the server.
^
Yeah, that makes sense. My own game is listen server + very autonomous clients.
My bad, I didn't mean to start ww3 in here I was just trying to find a detailed guide on dedicated servers
no worries ๐
possibly a noob question, but if i from one client want to update all other clients hud (ie. when i write a chat message), should i go through a Server RPC and from there, access the gamestate's PlayerArray to get all the PlayerState and from there to the Pawn and then finally to the PlayerController or is there a more direct and correct way? See screenshot below:
possibly a noob question, but if i from one client want to update all other clients hud (ie. when i write a chat message), should i go through a Server RPC and from there, access the gamestate's PlayerArray to get all the PlayerState and from there to the Pawn and then finally to the PlayerController or is there a more direct and correct way? See screenshot above
That was the first thing I tried, then realized I needed a way to display the servers to a server list. Which is then where I was googling the intergration of advanced sessions with a dedicated server which is where there is no good docs on. Everything is from like 2 years ago and apperently dosen't work the same no more
@twin juniper dedicated servers dont have a player
nothing really other than it doesn't relate to an actual user
a lot of the serverside code paths will be the same though
as far as i understand, a listenserver is a dedicatedserver + a client (someone correct me if im wrong)
unless you do something special like p2p connections, then it's not going to be much different from a clientside perspective
though using EOS for p2p might be interesting for the NAT punchthrough
the hosting player is ROLE_Authority
they don't have a separate "world" for the server
right, but using Has_Authority on a dedicated server vs. a listenserver will return true for both?
i meant that, if i start a game with 1 player = listenserver and do a printout of Has_auth, it will result in two lines: Server: Has Auth and Client1: Remote
the difference is the server doesn't close when the player leaves, these are the servers you see for games like Rust
and if i start with 1 player = dedicated server and do same print out, i get one line: Server: Has Auth
@empty bluff HasAuthority simply checks the local role of the actor. This will return true on the machine that spawned this actor. So if it is a server spawned replicated actor, it will return true on the server machine regardless of dedicated or listenserver and that same actor will return false on the client if the same call is ran in client side code. However. That same client can locally spawn an actor and check HasAuthority and that will print true on the client, because the client is the one that spawned it.
that is not true at all
if you use "play as client" mode in PIE, that emulates a dedicated server setup
hmm i forgot to mention that i did this print out from playercontroller
which seem to live on both server and client
the hosting player will always be authority over their own listen server, other (non-local) clients will behave exactly the same as a dedicated server connection
i just did a test, it says something different
In most cases, the argument between dedicated and listenserver is pretty moot if you code correctly. Listenserver client code will behave exactly like another client, and their server code will be isolated. In best case scenarios, you should be able to run your game as either a ListenServer or Dedicated.
then your test was wrong
this only applies to the hosting player
all other players will be identical in behaviour to a dedicated server connection
as i said, if i start as client (meaning i start a dedicated server and act as client), and do this printout from myplayercontroller it spits out two lines as i wrote above
try it yourself
that is not a listen server
i wasn't talking about a listen server buddy
you were arguing with what the hosting player was on a listen server
then you walk it back
ok
may have been unclear
As a muddied window. ๐
But yeah. If you start as client. Anything will print HasAuthority until you join a session and load into the server map. The client will have created all of the objects until then and will have authority over them because until that point, they're basically a Listenserver with no clients connected. Then they join the server and become a client where most things are replicated to them and they don't have authority over them.
thanks for that clarification... do you also happen to know if there's a better way than what i asked a bit up?
this: "possibly a noob question, but if i from one client want to update all other clients hud (ie. when i write a chat message), should i go through a Server RPC and from there, access the gamestate's PlayerArray to get all the PlayerState and from there to the Pawn and then finally to the PlayerController or is there a more direct and correct way? See screenshot above"
Never made a chat myself. But in some form, it'll end up being ServerRPC from client with intended message, and then multicast RPC to all clients to send and display message. GameState would likely work for that, or more appropriately might be an actor component on the GameState actor maybe. Someone else may know a better place to put it. But on Multicast RPC received on client, you'd probably get the HUD and get the chat widget and call a function to store and display the new message.
right... i tried making a ServerRPC which called a MultiRPC which then did the update of the Widget...
Which actor did which RPC?
sry im new to Multiplayer, keep forgetting to include info... bare over with me
ThirdPersonChar currently has just a click event handler to send a fixed string (to be a chatmsg)
it does this by calling a ServerRPC
it does this by calling a ServerRPC
like this:
(on ThirdPersonChar) Execution pin coming from the ServerRCP
it somehow seems wrong to me to do this, but can't explain why it feels wrong, but doing it as shown below seems more correct, but also more convoluted
And when you run this, if you put a print on SentTextMulti before the cast, do you get a print on all clients?
on second thought... using the multicast version may be ok, since it ends up with the same number of calls anyway, or not?
sec
LogBlueprintUserMessages: [ThirdPersonCharacter_C_0] Server: Hello
LogBlueprintUserMessages: [ThirdPersonCharacter_C_1] Client 2: Hello
LogBlueprintUserMessages: [ThirdPersonCharacter_C_1] Client 1: Hello
What about inside of AddTextBox? Make sure execution is making it all of the way there.
see above screenshot
well, tbh, i think adding that print string answered my question
it only runs 3 times
my concern was that i was worried it would be called 9 times
Shouldn't be, unless you get every player character and run a multicast from all of them. Only this one character that was clicked should run the multicast.
right
so i just realized i don't need the Executes on owning Client
it was only needed for adding the main widget at PostLogin
Possibly. Careful with that too though. Under bad conditions, you'll end up with clients missing UI if a packet gets dropped from the server telling them to add something to screen. UI should most often be initialized on the client side alone and populated with data it already has, and then bind functions from other objects to let the UI update itself when new information is replicated and available.
won't it be 99,99% secure if i make it reliable?
Possibly. But why bother with it? Chat box is a great example. If a client logs in. Why wait for the server to tell it to add the chatbox? Just let it's HUD's beginplay add it. Zero network code, no lag/latency. If an RPC is sent with a message when it doesn't exist, it doesn't matter. Don't do anything with it. Client wasn't ready to receive messages at the time. It can just add the chat to screen and set up all of it's own pointers to be ready for the next chat RPC someone sends.
aha hmm, makes sense to use the HUD's beginplay yes
One of the greatest things about networking, is that you're going to be spending a lot of time finding ways to do as many things as you can to avoid networking.
when entering the lobby though, at game start, wont HUD's beginplay fire already then?
Do I have to include something to use the _validation _implementation functions? Because when I append my function names with them they never compile because they are not included in the header
Not sure I follow? If you're in a lobby, and you start a new game, everyone's worlds are going to get destroyed, and a new HUD is going to get created anyhow. NewGameMode means new beginplay.
aha i didn't know that
aha i didn't know that
omg that worked like a charm, thx @kindred widget
Does anyone here know anything about Spatial OS?
follow up question: as of now, i have the widget stuff placed inside MyPlayerController, is there any particular reason i should not keep i there, or possibly move it to MyHUD?
why do I always see this getting used
in a UMG widget, there's the owning player
if this is a UMG widget for the chat
though an AHUD will also have an owning player controller
Personally. I prefer any and all UI stuff to go through HUD. Most game styles will already have a ton of logic going through controllers as is. Removing the UI to another class frees up a lot of complexity in the controller. And HUD is very easy to get with GetPlayerController0->GetHUD()->CastToYourHUDClass. So that makes it incredibly easy to get anywhere in code to have a client's local hud do something with UI it's handling.
another really good point man. I'll buy into that too...
Hello Guys i was trying to replicate placable object Material dynamically change when player press a button i tried to get it work
.....
After thousand of Test this one work
Is this wrong or what ?
Because any change it will cause it work just one side either client 1 or client 2
i would not use a multicast really for that
i would use repnotify property
also Has Authority on a server RPC...
@odd iron if i understand you correct, i think you should 1st call a ServerRPC and then from the ServerRCP call the MultiRPC to set the material, but i may be misunderstanding
@meager spade are rebnotifies reliable?
ofc they are
aha, i wasn't sure, thx
but they only update when the actor replicates
RPC can happen before an actor replicates
why lots of people fall into race conditions
ah that's what i messed it up with...
so if i would desperately need it to update, i could use repnotify and forcenetupdate?
but may as you say, be better on network rather than RPC
does not mean it will go the next frame, but will happen sooner
rpcs are fine
but RPC's are for one off events
like Explosions, etc
RepNotifies are for more stateful things
thing is a RPC only ever happens once, late joiners or people who were not relevant at the time, they will not get that multicast
i was chatting with a few before about sending messages to ie. a chat system or infopanel... would you say rpc's are better suited or RepNotifies?
but they will always get the property update
well depends how you do it
but ultimately will be a Server RPC from client to server
then client RPC to the client who should get that message
Replication for chat should only be a consideration if you want to keep logs and update them when a client rejoins or a new client joins. Very few games do it. And for something like chat, it's kind of a waste on server CPU useage for the check to replicate.
Replication for chat should only be a consideration if you want to keep logs and update them when a client rejoins or a new client joins. Very few games do it. And for something like chat, it's kind of a waste on server CPU useage for the check to replicate.
I have few knowledge about replication also ive tried to Replicate it from server but its just working on owner
@odd iron those RPC's need to be on an actor owned by the owning client
not just any actor in the world
Multicast is an exception, can be on ANY replicated actor
but must be called only from server
Good evening all, I hope you can help me riddle this out. I have a pawn and I want to teleport it after 2 seconds. This code teleports it on the server, but client stays on the same location. Any ideas what am I doing wrong?
I thought enabling Replicates and ReplicateMovement would be enough..
When using BP only, is it possible to define server name when hosting a server
if(CameraLockArm != nullptr && CameraLockArm->IsCameraLockedToTarget())
{
AActor* LockedTarget = CameraLockArm->GetTarget()->GetOwner();
const FRotator NewRot = UKismetMathLibrary::FindLookAtRotation(GetActorLocation(), LockedTarget->GetActorLocation());
SetActorRotation(NewRot, ETeleportType::None);
}
I'm trying to implement a lock on to target feature. Is setting the player actor to rotate to always face the target a viable solution in multiplayer? Are there any pitfalls to doing it this way?
how do I do this check without casting to the pawn?
I have an object with a collision that sets a variable, but I want it to only set the variable for the locally controlled player controller
it works, but I feel like there's a better way to do it
Is there any documentation on replicating behavior trees? I have replicated movement animations etc but the AI only acts on the servers player.
Generally you don't want to... AI should only run on the server.
Ok so do I do the AI in blueprints then?
you can do the AI in whatever you want, I'm not sure what that has to do with anything
BTs, blueprint, C++, whatever. Generally AI only runs on the server and whatever the AI decides to do is replicated to clients via normal means (character movement, triggering animations, etc)
pretty much exactly like a player would be... except instead of a remote client with some input device, it's an AI "brain" driving things.
I've made a blueprint that extends "character", and set it so that this character can fly basically
and the players can see each other when they spawn in, but they cant see each other move/rotate/etc
what could be the reason for this? This is my character class:
all replication stuff is checked i believe?
do i need to be doing something special in the player controller class maybe?
I'm having trouble dynamically creating an actorcomponent with NewObject that replicates -- any suggestions?
I call NewObject in BeginPlay
and I have called SetIsReplicated(true) and implemented the getlifetimereplicatedprops
I don't understand the multiplayer , In standalone i get a reference to the player character and work with in all the BP , now i am in a client server game , what should i replace this reference with? a foreach loop on all the player characters?
@raw quarry the Actor Owner and the Component need to be replicated themselves
the actor owner is replicated, and I've called SetIsReplicated(true) on the component, which should cover both right?
@lost dune you should really wait a couple of months with the multiplayer
you can't do MP without knowing any of the raw basics
Is this about replication?
show me the code
basically
void ARevenBladeCharacter::PossessedBy(AController * NewController)
{
Super::PossessedBy(NewController);
//Initialize revenblade abilities
if (characterAbilities && HasAuthority())
{
FString characterAbilityComponentName = "CharacterAbilities";
characterAbilitiesInstance = NewObject<UCharacterAbilities>(this, characterAbilities, FName(*characterAbilityComponentName));
characterAbilitiesInstance->setCharacter(this);
characterAbilitiesInstance->SetIsReplicated(true);
}
}
you forgot to register
and 3 backticks ` before and after format the code nicely
like so
ah cool
what does register do? I'm assuming you mean characterAbilitiesInstance->RegisterComponent() ?
you can add cpp after first 3 to get some basic syntax coloring too
If I've got a dedicated server running is there an easy way to use it as a listen server too? I.e. see everything that is serverside
if I run it in the editor is that enough?
all components have to be registered
those created in constructor get registered during actor setup
those spawned at runtime need register call done manually
o cool thanks for the tip on the discord tricks
and ahh gotcha, I'll give that a try
@winged badger any real difference if I do it in PossessedBy vs. BeginPlay?
depends
if you let the World call DispatchBeginPlay or not
if the World did BeginPlay, then no, not really
its just few functions down the line
Ok yeah that's what I figured
take note of AController::SetPawn
its the common function called on Client/Server
Server calls it from Possession code, Client from OnRep_Pawn
hmm it still doesn't appear to be working
is my HasAuthority() check correct? i.e. I create it on the server and it should automatically replicate the instance?
actually come to think of it.. should my 'characterAbilitiesInstance' variable be replicated?
oh right
characterAbilities is pretty bad name for TSubclassOf
if i didn't know the NewObject params off the top of my head, i would not be able to say what it is
Yeah that's fair
you can also do TEXT("CharacterAbilities") and skip the FString part
replicating CharacterAbilitiesInstance pointer isn't a bad idea
as it will be null on clients if you don't
there are other ways to initialize it, like overriding OnSubobjectCreatedFromReplication
but that is way more trouble then its worth
gotcha, I'll give this a try
the component is safe from GC even if not assigned to a variable as ReplicatedComponents TSet is UPROP
which mean you can probably find it in Locals on client inside that TSet
right right
hmm the component still doesn't appear to exist on the client
or at least characterAbilitiesInstance doesn't point to it
Is it a component or uobject?
ActorComponent
And you registered it ?
yeah
Where
void ARevenBladeCharacter::PossessedBy(AController * NewController)
{
//Initialize revenblade abilities
if (characterAbilities)
{
characterAbilitiesInstance = NewObject<UCharacterAbilities>(this, characterAbilities, TEXT("CharacterAbilities"));
characterAbilitiesInstance->RegisterComponent();
characterAbilitiesInstance->SetIsReplicated(true);
characterAbilitiesInstance->setCharacter(this);
}
}
Hmm
your declaration of the member and getlifetimereplicatedprops?
UPROPERTY(EditAnywhere, BlueprintReadWrite, replicated)
UCharacterAbilities *characterAbilitiesInstance;
Registering should add it to to the replicated comp set
also worth checking is it exists on server, as the class might be null
and I have DOREPLIFETIME(ARevenBladeCharacter, characterAbilitiesInstance);
with a Super call included?
i mean your PossessedBy doesn't seem to have it
so wondering if its a pattern ๐
Also never use edit anywhere and BP readwrite on a pointer like that fyi. Just asking for someone to break it.
yeah I just deleted the rest of the code in possessedby since it's not relevant for the code snippet
does the component exist on server?
hmm actually something else seems to be going wrong
attached some debug stuff and it actually looks like it's a valid object on client and server
so something must be going wrong with what I'm calling on it
got everything working now, thanks guys ๐
How do you replicate a construction script on an actor?
Yes I discovered that too. Sorry I should have been more specific.
I need to set the initial speed of a projectile based on a variable that is exposed on spawn. But that variable is always 0 on clients. It's the same result even when i set the variables to replicated.
You'll need to use BeginPlay then
Exposed on spawn variable has be set to replicated and you need to use BeginPlay for that
does begin play work for setting projectiles initial speed though?
Let me get out of bed and on my computer to check it out ๐ brb
thank you @thin stratus ill try it out
it does run on the clients, true. But the projectile only accelerated at it's default :S
the 6000 did not come into play. The projectile was still very slow
Just override velocity then
that works ๐
I have a car with a collision box, when someone walks in that box a widget should appear for the client. Does anyone know the method for this?
I've tried 4 different things, and each one causes the widget to appear on the server only, or not at all. I can't get it to appear for clients
Not sure how you setup your whole interaction widget stuff, but the idea is that you show it only in the Local Client.
If the Widget gets spawned in the Car BP, then the Overlap is probably giving you the Character that overlaps.
You can then check if that one is LocallyControlled and only show the Widget there.
Other setups could have the Overlap happen in the Character itself, where you can do the same check to show the UI.
@thin stratus How do you show it in local client? That is most likely my problem
Oh I figured it out, just needed to read what you said 100 times to fully understand it lmao thank you so much
anyone know where can find the overview for unreal low level network works 1. I want to know the information about encryption and compression of packet . 2. I heard UDP have NAT problem when server send pack to client , how does unreal handle this case, would it switch to TCP automaticlly?
Hey guys i wanted to know can AdvancedSessions/Sessions be used to make an android mulitplayer? is it possible?
if i have a MainMenu Level, and my HUD class is set to none, then when i select Host game i load up a new level. Once on that level, i want to initialize my players UI (Widgets) from MyHUD. What i was hoping i could do, was to change the HUD class to MyHUD class and utilize the begin play event then, but it seems ie. Level beginplay is too late to change the HUD class.
- No encryption, compression depends on the data 2) no, and it doesn't, and no
(NAT isn't a problem on modern platforms - Steam makes it a non issue if you're there, and if not, get yourself a NAT punch library)
@empty bluff Just make a separate GameMode for the main menu or other levels that don't need specific classes like that and set the level's game mode to that game mode. Then use your normal game mode in your game levels.
Or use the base game modes that default to native classes. Either way.
hmm, can't find where i define GameMode for the Level... i thought it was worldsettings, but that seem to be shared accross levels
Hello. In Fps game I spawn some actor and attach it to camera i server RPC. All other cluents see my actor infront of me, and that is ok. But, when I rotate camera up or down, only server see update position and rotation (essentialy player that spawned the actor always look in to it, like crosshair) on player that moves camera. Spawned actor is replicated with replicated movement. What am I missing?
Open your level, and go to the world settings tab and change it there. Usually right next to the details or world outliner. It should only change it for that one level.
ah got it... i was changing HUD for the same GameMode... silly mistake
hi, how can i create a sword collision which will work for multiplayer, like dealing damage to other players.
same as you would for single player
does any have any experience with ios networking?
this is not detecting other players
but it detects other things
how can i fix it what is the issue here anyone knows it?
ok, in case anyone else runs into this issue.... Found why my ios game was crashing on joining... by default it was pulling the configs from the engine defaults iosengine.ini and setting DefaultPlatformService to IOS, setting this manually to Null resolved my issue.
is there an alternative to using the built-in high level networking in UE4? like the replication systems, smoothing, etc.; everything
You can write your own networking layer if that's what you're asking.
or use whatever third party libraries you want, but you're pretty much on your own for either of those options
right, that's what i presumed but in another discord we got into a deep, heated discussion about whether that's possible; and some folks seemed pretty adamant that you couldn't
or not that you couldn't, but that it would be several orders of magnitude more difficult in UE because of how tightly the built-in network is entangled with the engine, to the uobject level
it's absolutely possible
just don't use unreal's built-in networking
I doubt you can entirely pull out the built in replication framework (it's pretty heavily integrated into everything) but you can just... not use it
I think @chilly mason is doing that for his game - iirc he's doing lockstep networking which isn't exactly easy to do with the built-in replication system. Also any game that does true P2P networking though I don't know of any UE4 games like that off the top of my head.
you have your own custom networking, right?
ah
wasn't familiar with that
of course they're nobodies since they're using photon
was gonna say, photon too... hmm
LOL is that like an in-joke I am unaware of ๐
(obviously just kidding, for the overly sensitive trigger happy lot watching)
sounded spot on
which discord
(as a joke I mean, people ripping on people using off-the-shelf networking solutions)
oculus start
yeah not on there
you have plenty of options for your networking with unreal network
2 months of writing netcode finally paid off as I now have deterministic lockstep P2P multiplayer in UE4. This is a great step for the game and with it, the biggest technical challenge has been overcome. Right is an Intel in the US, left is an AMD in Europe. Hundreds of spaceships, around 1500 bytes of network traffic per second. Traffic is encr...
here's a very crappy demo of my lockstep
very few things you can't do (host migration)
this dude was adamant that you could swap out the subsystem for a p2p system (like oculus p2p or steam, or EOS p2p) but you'd still be using the built in networking and thus the listen server, tickrate, replication stuff etc. (which obviously is true), and that building your own networking layer that circumvents that stuff entirely would be impossible for anyone but a AAA dev team
I gradually increase the unit count to 5000 I think
there's a big delay b/c of teamviewer, one compute is in the EU and my connection from here to there is abysmal
*computer
would need 2 minions and about a year for that i think
I'm not using anything from ue4 networking apart from FSocket
took me about 2 months I think with zero networking know-how so I imagine someone slightly experienced could pull it off in a month
writing separate network using sockets is one thing
getting unreal replication system to work p2p
I'm not talking about what Prime was describing
keeping all the options, having robust code, etc...
would take significantly longer
right no, i was asking the opposite, just writing your own networking layer and doing all the replication and stuff yourself
testing alone would take 2 months
pretty much exactly what @chilly mason is doing here
2 months
my man
2 months with experience and it working, but what about all the edge cases and issues?
not sure there are many edge cases
haven't had a single desync in Shipping code so far
it's more like a fixed set of challenges to solve as opposed to client-server which is a lot more complex w/ a lot of crap
what library did you use ?
for what?
your P2P networking
but bottom line: if i were capable of, given only a low level networking library capable of connecting clients and firing bytes to each other, build my own high level networking framework for a game with parity to something like photon (replicating properties, sending messages, smoothing and correction, delta compression, etc) in another engine, is it safe to say I could probably do it in UE4 as well?
not sure what you mean
Glass likes to do stuff himself ^^
including the tcp/udp transport layer?
udp
interesting
so you didn't use a base framework for your UDP stuff, just did it all yourself?
only stuff i have done, always used ASIO library
I'm using FSocket from ue4, that's pretty much it
in my Flight Simulator programs, i used ASIO as the library for that, its really easy to use
@chilly mason so your game is true p2p then? there is no listen server/master client
like the old 100 archers paper
exactly like that
awesome
I wrote a small matchmaking server w/ NAT punchthrough
since you need that sort of stuff for p2p
and to my detriment I've chosen std c++ for that which I kinda regret :)
might do a rewrite as a ue4 Program
what's cool about p2p is that you don't need to pay for servers
just need 3 potatoes to do the matchmaking for like $5/month each, one in the US, EU and Asia
of course players can just set their p2p up directly but routers are a pain in the ass so nat punchthrough is good to have
aren't they expensive?
eh, kinda
$95 one-time for 100ccu, $95 a month for 500ccu
i'm making a VR game for Oculus Quest so if I broke 500 ccu I'd be in like the top 5 games on the platform so I'll cross that bridge when I get there ๐
hehe fair enough
You also pay for traffic with at least PUN.
oh yeah that's another issue huh
Thatโs for me the major issue, because the more people play the more bandwidth they use lol. And it also of course heavily depends on your game. If it was for just the CCU limit then itโs no problem, but unfortunately ๐
Per second?
yeah, the 500 CCU plan comes with 1.5TB, given my compression and messages/sec I think I would come under that
er well not if people played 24/7, I guess that'd be tough to evaluate haha
Would recommend really looking into that before doing anything, if it turns out you use a lot more then thatโs a big rip
I'm compressing and encrypting all my traffic
don't ask why I encrypt, I probably just wanted to try that stuff out :P
Does anyone know what the most used cross play services are used with Unreal? I know Playfab and Photon exist, are there other good ones though? As I assume we donโt truly know the most used one
I recall seeing a list somewhere but I canโt find it anymore ๐
define "cross play services"
none of the things you mentioned have to do with crossplay specifically, and photon is not the same thing as playfab
Services that allow me to play with friends over multiple platforms without having the limitation of โI play on a console so I canโt play with you on Steamโ
So basically relays
that's not really what's required for crossplay
just need a matchmaking server
the only thing that matters for crossplay is a way to verify/manage accounts from different services
and matchmaking ^
doesn't ue4 have an off the shelf matchmaker
playfab does that to some degree, EOS does it, I don't know that photon has that
via epic online services
not really built-in
but yeah, I think EOS has a matchmaking system.
so does playfab
if you're interested about playfab btw microsoft is holding a larger conference
apr 20-21
(there's also graphics and other tracks)
I still feel like Iโm not understanding this correctly, a โmatchmakerโ is what connects people right? If it was a dedicated server it would connect people to that dedicated server, but what about listen servers. I donโt assume that handles connecting people to each other through whatever necessary right?
As probably the best example a router of someone blocking direct connection with the listen server someone has on their PC. How do services fix that issue?
in the context of p2p, a matchmaking server is what does nat punchthrough (to get around routers) and also what keeps track of active players/sessions
Does NAT punch through always work though?
To my knowledge it doesnโt always succeed right? What then? Or does it always work?
player 1: I want to play with player 5
matchmaker: player 1, open a udp port and tell me what it is (along w/ your ip)
matchmaker: player 5, open a udp connection to player 1's ip and port
player 1 & 5 can now connect to each other
if nat punchthrough doesn't work then you either tell them to set their router up or use something like steam's network thing
which is a relay service
or just don't let that player host a listen server (if that's an option)
there are no listen servers in p2p
fair, but nat punchthrough is still relevant to listen servers ๐
Are there any services that provide all these things, is that even common or is that something no one offers? Or is NAT punch through failing such a small chance that no one cares about it?
Steam provides it for free provided you use steam sockets
they're called relay servers I believe
Steam Datagram Relay [BETA]
NOTE: Carrying traffic to your dedicated servers over SDR is a beta feature, and is not a Steamworks feature we can offer to all partners at this time. There may be technical or capacity issues that prevent us from offering it to all partners.
it's practically a mini internet of Valve's
afaik dota and starcraft have similar constructs
pretty sure Photon has something like this
and are making good money on it too :P
the matchmaking server just needs to send an instruction to the host server to send a message to all clients
so its router doesn't discard messages from them
Thatโs what Iโm trying to figure out though, because the limitation with using that for free is rip crossplay for other stores. Is it even possible for small games to use services that provide this without dying because of lack of money instantly? The other problem of course is that if a store or platform doesnโt offer such a free service then itโs also a rip.
obv not required for public server
Your question is at least part of why P2P is uncommon these days - autoscaling dedicated servers isn't hard and it's generally simpler to use dedicated servers than P2P.
and way more costly
infinitely more :D
there was a GDC talk about this btw hold on
definitely, but if your alternative is either a bad experience or relays (which also cost $ if you can't use a free service like steam's) then it may not be much worse
as with everything, "it depends"
Dedicated servers are much more costly than just relays / matchmaking servers to my knowledge because you obviously also need to host the servers.
the good thing about relays is that they're relatively simple to write for yourself and then it's just a matter of finding some potato servers around the globe that have your bandwidth requirements
simple b/c all they do is forward network traffic
In this 2017 GDC talk, Sony's Claire Blackshaw introduces a wide range of online features, highlighting easy features most platforms provide for the benefit of game programmers.
Join the GDC mailing list: http://www.gdconf.com/subscribe
Follow GDC on Twitter: https://twitter.com/Official_GDC
GDC talks cover a range of developmental topics i...
I think it was this
I mean yes, but you also need to host it all your self then and keep it all up. Which may not even be too bad when youโre a small game I guess.. Along with a matchmaking server of course. But that does become a rip if you probably get more than like literally a few people. The bigger it goes the worse it gets ๐
hosting a server these days is dirt simple
digitalocean -> create droplet -> yes -> install docker -> server is up
you can go a step further and configure some azure / aws scripted nonsense
or just write a simple script that pings your servers and if there's a timeout just send reboot over ssh :P
but you only have to worry about any of that once people are playing your game, at which point you should have ๐ธ for better infrastructure
https://youtu.be/HVpcRXVkQl0?t=2560 there's the timecode :P
so she's saying that "p2p is extremely complicated" -> ignore that :P
"the reason it's the default option is b/c it keeps things cheap"
The video was pretty interesting, thanks for sharing ๐
Didn't watch all of it, but a decent part was interesting to me ๐
Hello, we are currently developing a game using steam sessions. When the game is completed we want to send the players to an EndGameLevel which then leads to the MainMenu. However, we are not sure where and when to call the destroy session function. In certain, cases if the server calls destroy session before the client the game crashes for the players. In other cases, both players are able to return to the MainMenu but none are able to create or join another session without closing steaqm and reopening it (hinting towards the session still being in progress).
TLDR : Where and when do we call the destroy session BP? Client? Server? Both?
Also our game has two players, and is run as a listen server.
BeginPlay in MainMenu
Is #if WITH_SERVER_CODE supposed to be only defined in server builds? meaning that all the code I put inside that preprocessor statement will not compile on client builds?
It seems like it's defined to "1" in every single file so I'm confused. How am I supposed to find out how things like these work?
its stripped before compiling, yes
what do you mean by "its stripped" ? as in they remove that whole #define line??
It's a preprocessor definition
So the compiler evaluates it when compiling and processes #if WITH_SERVER_CODE blocks accordingly, keeping or removing the code within
Hey guys, how would I go about networking a double door and having both doors open at the same time? So basically I am calling a Server RPC to open the door, which calls a multicast RPC to perform the animation of opening. One of the doors open at a time but I think that it is dropping the function of the other door due to reliability. I will post screenshots to clarify when somebody replies, I don't want to flood with screenshots
I would think that you'd want to use a rep notify to open/close the door because you're changing state. A pretty simple state, but changing state none the less.
I tried the rep notify and it worked but it was still the same issue. Only one door works at a time for some reason. I think it has to do with trying to run two RPC's at the same time and it drops one of them.
If you want them 100% in sync then use a single actor with 2 mesh components, one for each door.
do anim blueprints not replicate automatically? Should I just do everything in montages???
Anim BP will not replicate, you need to replicate the state that drives the anim BP.
method please kappa?
Say you have a bool which you read in the anim BP to switch pose or whatever, the bool itself should be marked as Replicated.
oh I see thank you
I set it up again and it opens both doors, but it does not play the animation on both doors, it will play on one door and then the other door will just open.
I am running that after a few checks but basically just when I press F it calls both of those
I suspect your problem is perhaps in the Open Close function, calling two reliable RPCs like that is a bad idea, but should still work.
Yeah I figured that was the issue but I cant seem to think of a way around it. I was thinking maybe just doing two collision boxes and open the door that they are standing in or something like that. A little bit more annoying but probably more reliable.
No, replicated bool for state is the way to go, and observe changes in state via OnRep, as the other guy said before.
Player approaches the door and sends RPC to server which just changes the bool
OnRep is fired when bool flips to open and you play the animation
ill try that out again, I have a bool already set up for it with an on rep from when I did it before but maybe I did it wrong, im gonna try again now
Make sure you only write to the bool from within Server RPC, clients should generally never modify replicated vars.
I tried that, it did not work, I tried a few different ways. I am a bit tired now though so I will have to continue looking at it another time. Thank you for helping me with it! I'm sure tomorrow when I look at your messages my brain will process it better lol
That function name gives an idea what the issue is. Are you changing the bool to true then back to false or vice-versa in quick succession?
If you do that, there's every chance it will never replicate because the next time the actor is considered for replication, the server sees it in the same state the client currently has it. If you must open/close things quickly, an incrementing counter is a better/safer approach.
Ahhhh yes, I need to have two separate bools, one for each door?
No you need a counting integer or byte, increment it by one for open, and again for close. Use modulus on it to determine whether it's odd/even and therefore it's actual closed/open state
Two bools could still have the same issue
It helps if you remember that you aren't guaranteed to receive every change made to a variable, only it's final state. If the server thinks the client is already in that state, it won't send anything.
So incrementing a counter is a more reliable way of making sure the server sends a change
Oh okay I understand what you are saying. I will implement this tomorrow, thank you!
Guys??
Advanced sessions is just Blueprint for the online subsystem
so it will work if i set the subsystem to GooglePlay?
Pretty certain GooglePlay doesn't have a sessions implementation.
Just identity/purchases etc.
Oh and achievements
oh how can one make a android multiplayer using UE
Google in "drops support for something" shocker.
I'm not familiar with google and what services it actually provides for games - but my best guess looking at that, is that you would need your own master servers to advertise and find sessions. Such a thing is far from trivial to implement and support (and obviously not free). You could probably support LAN sessions easily using the engines' basic net driver if two devices are on the same wi-fi network.
There's bound to be a few topics on this out there though.
I learned my lesson with google/mobile, and that lesson was "nope".
lol
so in other words currently its not possible for a solo dev got it
I mean sure it is, with your own service, possibly EOS
But multiplayer mobile is tricky and Unreal's multiplayer model is built for real-time action games
Mobile multiplayer is often more of the slow burn type
Hi everyone. I'm using seamless travel to have the server change maps, but I want to ensure that all players clear their viewports. I have an issue right now where if a player had a menu up when the map changed, then an orphaned copy of that menu remains on the screen, and pressing the menu button again just brings up a second copy over the top.
Is there a function in C++ I can override to capture the point at which clients seamlessly travel, so I can add a bit of code to close all open menus?
I tried doing it in the loading map blueprint within BeginPlay, but it doesn't seem to work
Ah lovely, that gets called during a seamless travel as well?
Ah sorry, just looked at the function definition and there is a parameter for whether it is seamless
@meager spade Thank you ๐
anyone followed "Unreal Engine 4.26 Steam Multiplayer Beginners Tutorial" video ?
I don't understand how the game can find a session like that out of the blue over the internet
he tests a listen server both with and without steam
I think it still uses steam in both cases
Anywho - yeah, that's what I used to be able to get my stuff connected across the net. Steam has to be running though. Which, personally, I'm not too concerned about at the moment. I'd like for it to be platform agnostic, but I'm not at that level just yet. Shouldn't be too much of a headache to change over once I am at that level though.
Are you just unsure how the connection works?
yeah the video just isn't very clear
In what way?
You get routed through Steams servers
You use their services to find hosted games
What timestamp?
15:57
He keeps it as true
but says you can debug with false
Turn it to false and give the packaged game to a friend.
Then just start it up.
Try to connect to each other
with sessions ?
Yeah.
with no ip ?
Just keep everything as is, change that to false
and it should work ?
Try it
I will, rn I'm getting "LogOnline: Display: STEAM: OnlineSubsystemSteam::Shutdown()"
and searching through the discord's history it seems I'm not alone lol
how does it work then ?
Since you've followed the tutorial it might be useful for you to read http://cedric-neukirchen.net/2017/02/14/multiplayer-network-compendium/ now
even if it's not working, should send you in the right direction
yeah I've read that
I suggest re-reading it to get new understanding for the questions you're asking: "By default you will use the 'SubsystemNULL'. This allows you to host LAN Sessions (so you can find Sessions via a Server List and join them in your LAN network) or join directly via IP. What it doesn't allow you, is to host such a Session on the Internet."
In the compendium it describes why it wont work.
is it? I thought it said you could disable subsystem to troubleshoot, i.e. test on lan that your listen server is working
that's the implication at least
I understood it as disabling and keeping everything else, i.e finding sessions on other networks
You understood it incorrectly.
Anyone experience "NumOpenPrivateConnections" from an FOnlineSessionSearchResult always returning 0?
sorry, Public, not private
Result.Session.NumOpenPublicConnections is giving back a 0 on a LAN setup no matter how many clients I toss into the game
.< I mean it's open, all of them are open; I'm getting my numbers all mixed up
so my math, which is NumPublicConnections minus NumOpenPublicConnections is always returning 0 for how many players are in the game
Hey guys, how is going? any hints on what can be causing the visuals going twice as fast in the autonomous proxy? I started to port my game to multiplayer and I wondering what can be causing that
ah we had this once ๐
if (Mesh && IsReplicatingMovement() && (GetRemoteRole() == ROLE_AutonomousProxy && GetNetConnection() != nullptr))
{
Mesh->bOnlyAllowAutonomousTickPose = true;
}``` was caused by this being false
this is set in PossessedBy in ACharacter
love how all that Character stuff consistently breaks encapsulation
yh
Hey guys. I'm working on a grenade mechanic in a third person shooter. Have been going back and forth between using simulated physics with an AddImpulse to launch the grenade - which generally looks the nicest but is quite random at times, and very janky when replicated to clients - and using a Projectile Movement Component with bounce enabled. The PMC seems to produce the most reliable results so far, but my biggest issue with it is that the grenade just keeps the orientation it had when it left the hand. As my grenade model is cylindrical, it looks like the characters is always winning the bottle challenge because it never falls over. Anyone have any tips for that? The PMC tutorials I've found all seem to use simple spheres as an example
Use a sphere collider as root, do whatever you want to mesh rotation
Also I'm pretty sure the projectile movement component supports spinning
if not can use a Rotating Component
I spawn a lot of fire particles via multicast in a controlling actor in my levels, it burns across the map. Is there any value to passing all the player controllers an array of vector locations, and having them spawn particles on client only?
Versus my 1 multicast of the same array
Hi guys,
I made a class SoldierTeam which stores data of one team of ASoldiers (a character for AIs and players). In this class I have a TArray of pointers of ASoldiers that I'd like to replicate. I want this array for the UI. Unfortunately, the array is empty on client side. My soldier class and SoldierTeam are set to replicated. Also I made sure my array is replicated with UPROPERTY(Replicated) and GetLifetimeReplicatedProps.
Any idea where could be the issue ?
I read somewhere that an actor should have an owner to be replicated. In my case, a soldier has its controller as owner on server side. Can't be possible of course on client
The owner stuff is for RPCs. Simple replicated variables aren't needing that.
Ist that actor set to replicate?
What type is SoldierTeam of anyway?
@clever swan
What's the difference? It's 1 array per connection regardless right?
Running into an odd situation. I have check points for multiplayer. Since these light up and track each player's progress, the best way I could think of to deal with that is have the checkpoints laid out on the map, with an index variable (0 to however many is on the course) and then set them up to "only owner see". Then before play starts, go through the checkpoint array and duplicate all the checkpoints for each player connected, it spawns a new copy of the checkpoint on the same place, and sets the player as the owner. This is a function called from the gamemode, so it has authority. The problem is, the function seems to be executing, but I'm getting weird results: I already have Checkpoint0->X in the level, but when I run the foreach on that array of checkpoints and spawn a new checkpoint in the exact same spot, the result is a checkpoint with the exact same name. Doesn't make any sense to me. I figured that when it spawns a new one, it should keep adding to those numbers, so if the last checkpoint for player 0 is 28, then the first checkpoint for player 1 would be "checkpoint29" or something like that. Instead, the arrays for player 0 and player 1s checkpoints seem to be printing as identical.
I've set a breakpoint and a print right after the spawn and verified that the actor it's spawning has the same name.
Why not just have the one set of Checkpoints and they keep track of each player that runs over them in an array?
Why do you need separate checkpoints is a question.,
Because they have visual effects that need to be shown to each player.
So only trigger the effects on the local player if that player was the one to overlap it first?
it's got nothing to do with being first. The next checkpoint shows as a different color so that players know where to go, this is flying so it's not like there is a track to follow. The next 3 checkpoints are visible to the player.
Ok so if its not about first, then just trigger the effects when the local player hits the checkpoint
You dont need to have separate sets of checkpoints for each player.
If they are all identical.
A check point will either be "next checkpoint color", "future checkpoitn" or "invisible"
Just check if the pawn that overlapped it has a locally controlled playercontroller, if it does, trigger the effects change.
We also have local multiplayer.
Well, think about the necessary components you have available to you that will be able to filter out the appropriate time to trigger the effects for the appropriate Player...
Just check if the pawn is an Autonomous Proxy...
With 2 player, we just duplicated the visual effect and had a "only owner" and "not owner" but we've increased to 4 player local and maybe 6 or 8 online. With 4 player local we can't do that anymore
so we came up with this solution that works in both scenarios.
How else can we split that up for local multiplayer? The whole "local player" doesn't work there.
because everyone is on the same machine.
Yes.
As far as I know you can't hide things from split screen players unless you use only owner see.
Ive never worked with Splitscreen so im not sure if it creates multiple worlds for each player.
It doesn't
they all reside in the same world.
which is why we had to duplicate the checkpoints and set them only owner see and set each player as an owner for a set of checkpoints.
Ehhh that still seems like a terrible workflow.
Im not sure on what approach would be best then. Maybe that is the only solution.
The only way I could see modifying that would be to have a checkpoint actor that is tied to a set of checkpoint emitters.
one emitter for each player, which they are the owner of.
On begin play have the checkpoint spawn an emitter for each player and set them as owner.
then update the emitter as the player overlaps.
That would probably work fine in online play as well wouldn't it?
and keep things simpler.
hey guys, I'm receiving the following error when calling a server RPC:
"Error: Replicated TMaps are not supported."
The thing is, I'm not sending any TMaps to the RPC. I'm sending a USTRUCT (aa blueprint one, created within the editor), which in turn contains other structs and an array of a struct. NONE of the inner structs use TMap either.
What's up with that? I don't get it
Is there maybe a limit on the number of struct that a struct can contain when it's sent through a RPC or something?
Whooops sorry, he's right, someone added a TMap to one of the struct
My mistake ๐
@somber glade You have to think a bit different for Local Multiplayer. Instead of having a Checkpoint per, you could simply have 4 indicators on one checkpoint. E.g. colored.
That way you can keep one Actor for Online and Local. Have the Online one only show the effects on the local player and for Local Multiplayer you simply update the specific indicator on the checkpoint.
It might also help to check how other games with local coop solve this.
I'd be worried about that being overly busy on the screen for the players, but I could try that as well.
since we're flying and we can have tracks that cross back on themselves, we're only showing 3 checkpoints ahead
Yeah, I would experiment a bit before spawning multiple checkpoints in the same place
But I would 100% try to think different about local vs online
I made a local & online game and we had to rethink a lot of "easy" online solutions for splitscreen
I mean sure, you can spawn 4 checkpoints
Make each player the owner of one
And hide them via the owner only see stuff
If you can make sure that this doesn't affect performance and doesn't break (cause you most likely need to either spawn them dynamically with a "Spawner" that sits where the checkpoints should be, or update 4 pre-placed ones accordingly), then go for the simpler solution.
We've already got, the set of checkpoints in the level. My solution was to have the checkpoint manager go through and use that to duplicate it for the rest of them. seems to work fine in local, but in multiplayer, as I indicated above, when it was duplicated the checkpoint it was returning a result with the same name, which made no sense to me.
For example: CheckpointArray[0] had Checkpoint so I took the transform and other important information from it (index, course, etc) and just spawned a new checkpoint with those variables but set a different owner and stuck a different player number in it. When it spawned, print was telling me that the new actors name was "Checkpoint" just like the one it was spawned based on
Even if I go a different route with the checkpoints, I'd like to understand why that was happening.
I've got an issue with getting my widget to work on my clients. I got a bind in the widget to show the gamescore (as you can see in the image). Now this works for the listen server, but the clients do not see it. When i just print the gamescore from the playerstate, it's updated, so I know my score system is working. I really have a feeling it's in this bind... Anyone knows what my problem could be?
can someone point me im the right direction here? on "gamemode post login" I am adding the new player controller to an array. after that, i want to run an event on the newly connected client, initiated by the server.
but the result is always that the event is execute by the server...
Show the red node for that event
not my first network bp but i am often unsure about rpc event settings in those cases...
@quasi wyvern that should be a run-on-owning client event if you want to call it on server and run it on client
@dark edge thx, tried that on both events and on each individually, but nothing happened :/
Ok I did some more debugging and testing setting gamescore from the pawn and from the gamemode and now I'm even more confused ;). I think I tried all of the run on server / multicast combinations here but I can't seem to get the client to correctly update the playerstate even If I'm asking the server to do it for me. I think I'm using the wrong google searches as well since nothing pops up that even remotely looks like my problem ;).
It all works on both the client and server when I use a test pickup which sets all values in the playerstate. :/. So both the widget and the playerstate get properly updated. Setting the playerstate variables to replicated didn't change anything btw, I just tried a lot of stuff ๐
well you have a server RPC in game mode
client can NOT access GameMode
so how will that server RPC ever work?
i really suggest you read the network compendium
you have done things really wrong
how hard would it be to be able to connect two PIE sessions together
or editor standalone instances
Pretty easy. One opens as listen server, other joins
Routing might get a bit weird but you should be able to launch game twice, have one open a map as listen, and the other open localhost or 127.0.0.1 or whatever.
Won't work with Steam tho, you need 2 computers and 2 accounts for steam sessions.
oh sorry I meant two pie sessions across two computers
obviously you can connect two pie sessions locally, thats what unreal does by default to get X number of players working
@high current simplest and most basic way is just to "open hostip" and it'll work.
You'll need to port forward if it's over the internet.
I remember that not working
I would make a main menu, and have a host and join button. Host opens map with listen option, join opens the IP
something with editor signatures mismatching
It absolutely does work. Are you guys on the same editor version?
yes
No error, sessions are not found and Open IP doesnt do anything
Are you sure the hosting machine is actually hosting? How are you launching it?
@dark edge Yes it is 1 array per connection and no difference there. I was thinking if the function that spawns the fire is called thousands of time per game round, could some kind of performance or networking benefit be achieved by changing what actor referenced that array.
Which also might not matter, I'm pretty novice with unreal and self taught. So it could be a silly question
Just having a hard time making the quantity of fire particles I want to appear, appear at 60 fps, so want to make sure I am calling from the best places
@limber mortar when in doubt, just think of what the minimal amount of information is required to be sent everywhere so the game stays in sync and you'll be good. For example, for a first person shooter, really all you need to network is everybody's position, velocity, and aim direction. Things like animation state are all derived from that
while also looking at the emitter itself
yea, thanks, that makes sense
following that logic I am going to test calling the fire particles on clients only
@limber mortar so what exactly are you trying to do here? It seems kind of weird to have to replicate something like checkpoints thousands of times
I have a game where a wildfire burns across the world and threatens a town
choppers, engines, dozers, the physics get affected when my fps is too low
so I have fire particles spawning across the map
and 1 actor controls all the spawns
It takes each damaged area, and spreads the fire around via damage. Each damaged area has a location saved to an array, and each tick the actor will take newly damaged array locations and spawn an emitter
so once per tick this actor goes through a for loops of new locations and applies damage, and spawns a flame
Each fire 'cell' that spreads has a random timer to initiate the spread between 3-4.5 seconds
to prevent them all firing off at once
@limber mortar how many cells in total do you have?
Like what's the resolution of your fire map
Let me check, the cells fire can spread into are built into the level
but the cells are not the actor that spawns the fire
505x757
The cells are basically the base data the represents whether an area is on fire or not right?
yes
those little white balls represent a cell on the ground, it takes damage, adds its location to the array
then the controlling actor fires the damage around it and the particle generation
its not a big level
but I have 15-20k cells
I made a system to auto place them
the for loop itself doesn't seem to be an issue. If I disconnect the emitter spawn pin, then things run perfect
but hard to have a fire game without fire eh? ๐
So I am trying to do 2 things, Optimize my fire visual fx, and make sure all the networking of calling it right is best practice and correct
small fire such as this hits performance too much
gets worse when I add the smoke and black ground decal in hehe
hmm so even on a packaged build we cant connect with open IP
our ports might be not configured with the VPN
but just to be safe is there like an example project out there provided by unreal that has the simple host/join sessions thing
You'll need to LOD your particles heavily
VPN? That's where I'd look first. Didn't know you were using a VPN lol
yep, company VPN, we'll check with IT about the ports