#multiplayer
1 messages ยท Page 631 of 1
yea but like I said, it's working, but because of the low net update frequency of playerstate it can take a second before the score gets updated
Ahh ok I get you Adriel. Thanks
If this is a shooter, ignoring prediction, the only client to server RPC should be when you fire the shot. Prediction makes things a little bit trickier
I will ignore prediction for now ๐
Try making a delegate in the pawn and hook to it in the HUD class and setup a bind then Fire -> Client/Server predict -> Both update client already fires and server validates -> Server overwrites if incorrect
Ok thanks for the help guys, even after reading exi's guide multiple times it's sometimes still hard to wrap my head around. I do not have a programming background, so that might be the issue ๐
Appreciate the help
You don't want to predict things like score, there's no sense in it at all. Just accept that some stuff will be inherently latent, it doesn't really matter anyway
You want to predict as little as you can possibly get away with to make the gameplay acceptable. If you take it too far, you just end up with a mess of problems and race conditions that area really hard to debug once you actually ship.
So in this case it would just be best way to setup a replicated variable being set only on server and hook to the OnRep of that variable? Just trying to get my head around it myself
That sounds like the "fastest" option to me as well
But like I said, I'm far from being an expert ๐
@bronze summit you predict only things that your player needs to have an immediate feedback on
like pressing fire and seeing the gun fire immediately, not 0,2 sec later
Hii Do we need to buy a server for multiplayer game for Android
anything else, can wait for server
Hi, I've got some a question about the PlayerState...it appears that GetPlayerID() is really not a good way to differentiate "unique" players (I'm seeing the same ID used on a LAN connection). Is this only useful in a real subsystem that isn't the null? Is this generally a bad way to ID the uniqueness between players?
I tested by having BeginPlay() print out the ID and I'm seeing non-unique numbers print out when players join the session
omg, i found out my problem with the player state being invalid, i forgot to pass in the player controller in the blueprints ๐คฆโโ๏ธ
BeginPlay() on the PlayerState fires twice when a client joins, once for server and then once for client...will the UniqueNetID be the same for both, or is this going to be different based on where the BeginPlay() executes?
How would I go about preventing the ListenServer from executing functions twice?
the host is adding themselves to an array twice (and apparently "AddUnique()" is not catching it)
so, I think I've hit a but
bug*
PlayerState's BeginPlay() fires twice
I attached a print to it to test if this is happening once on server and once on client, and it's twice on client, with two separate BP instances (C_0 and C_1)
does this make sense to anyone?
Nevermind, it's firing for every replication when a client joins of already existing player states
Hello everyone, I'm having an issue with Gamelift/AWS. Using UE 4.25/6 source, VS 2017/19. I am able to build both plugins to source (even with 4.26), and everything looks fine... until I go to build the dev server, no matter which release of UE and/or VS I try. Then I get errors, and most importantly, no server build. Any ideas?
does repnotify trigger when players join? i need to figure out how to handle the state of an actor for players that might join a session later
or do you just need to run stuff when the server hands out a new player controller to a joining player
{
if (Controller)
{
return Controller->GetControlRotation();
}
return FRotator(RemoteViewPitch / 255.f * 360.f, GetActorRotation().Yaw, 0.f);
}```
Hey guys, I was watching this tutorial and I don't understand why RemoteViewPitch was divided by 255 and multiplied by 360. It is a uint8
Is there any way to get the remote view yaw?
Very important question for me: Is there a difference between testing with clients only in standalone mode and the other modes like new editor window etc.? In standalone mode my game is quite... buggy and doesn't behave as it did in other modes
Can't figure out how to attach the override audio listener node to my ear mesh in multiplayer. Any help?
Yes I'm pretty sure.
It's good for state driven stuff.
1: Here's the state (variable value)
2: Do something with it (function)
@distant wave I think that division/multiplication is a way of converting it from a range of [0, 255] stored in the uint8 to [0, 360]
so if RemoteViewPitch had a max value of 255, that would translate to 360
@dark edge roger, thank you! working on a multiplayer replicated destructive foliage for larger objects like trees. need to maintain which objects were destroyed for gameplay reasons (collision, vision etc)
That's basically packing pitch into a uint8 which has 255 values
why didnt those dumb Babylonians just use 8 bits for angles lmao
Thank you! I checked the Pawn.cpp and .h and I noticed the comments they made
I also created my own RemoteViewYaw just like they did with RemoteViewPitch
So now I replicate that head rotation nice and smoothly
is there any video/tutorial/project where I can see a really good working **multiplayer **melee combat system ? Like action combat (chivalry / mount and blade etc...) thanks ^^
Hello, would it be fine, if I post a lengthy question here?
If its too lengthy use a pastebin, but sure
by too lengthy i mean like 2 posts or more ๐
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
dunno, I thought I'd do it like this anyway, as it's some paragraphs
ah]
there was a number of issues in 4.24 version of SteamOSS
ours got fixed upgrading to 4.25
4.24 to 4.25 is quite painless
we had just 1 issue was our whole game went bright
but that was cause they turned some feature on by default, can not remember what it was now
yes, replicated vars are shared on relevancy update
thank you!
In a multiplayer game setting, what would be the best way to give each player their own dedicated instance of a room while still connected to the main server? E.g. they are on a multiplayer map, but can enter their own instance of a dungeon if they go through a door.
Broad strokes the two approaches I've considered are: Spawn a new room/dungeon instance for each player programmatically on the fly. Or (b), use a single dungeon room and take advantage of net relevancy to isolate players from each other (plus any mobs/items/etc in their dungeon instance)
for (b) I'm pretty worried of introducing bugs if I don't get relevancy correct for every player, mob, ability, and effect. It would be pretty wild if a stray projectile from someone else's instance killed your boss, for example. Or if you could see someone else's loot on accident.
For the first idea, I'm having trouble with doing this programmatically using a BP actor, because you need multiple actors. At minimum, the static mesh and a nav mesh bounds volume. What kind of primitive can I use to load on the fly? Is sub-level streaming something I should look into?
Also, I tried generating nav mesh bounds programmatically and it had a lot of problems. It feels like I'm doing this the wrong way / uncharted path
With your second approach you could replication graph. Forget net relevancy.
So i've got this error on my client: LogOnlineSession: Warning: OSS: No game present to join for session (GameSession)
and my PostLogin is not firing in my GameModeBase- I'm wondering if these two things are related?
You should already place the nav mesh volume in the map, and when spawn dungeon actor per player it should adopt to nav mesh(as per my understanding).
Are you using any OSS?
Thanks @rich ridge
I do not believe so. I'm very new to multiplayer in unreal
So just have one massive Nav mesh volume that can accommodate potentially 10s of dungeons?
I have an existing Nav mesh volume for the persistent map
Yes and I believe you need to make a grid of 10, so that you could spawn 10 dungeons
Don't overlap dungeon acotrs. It might give you unexpected behaviour
Yeah, that possibility concerns me
What do you mean a โgrid of 10โ? Is that a Nav mesh volumes thing or you just mean how I lay out the dungeon actors efficiently?
Something interesting is that this only happens when running my Development Server build and Development Client build together- but when I open the Editor and use PIE the post login fires. and i dont get that warning for OSS either.
I meants like make grid like 5X2, or 2X5 grid and spawn every dungeon actor at center of each grid for each player.
Yep, makes sense
Ohh I see now, basically while inside of editor it uses default OSS , ie NULL OSS to join, but when you actually build server and client separately, then you explicitly need to specify the OSS
Reading about replication graph now, it sounds very powerful
Make a list of special Actors that are always (or never) relevant to certain clients. A similar always-relevant list node could be made for individual players, or for teams of players.
^ from the docs
Replication graph was developed for fortnite
So I could potentially reuse a single dungeon, with each boss/item/player combo on its own list
Ah thanks! How would i go about that?
Yes you could use, as I don't know much about your game specs.
For starters I would recommend go through Advanced Session plugin.( Don't touch advanced session steam).
The idea is that players can play together on the map, but when they go into a dungeon room to fight the boss, itโs a private instance so they donโt get interrupted by other players
Is it easy to just set it to whatever the PIE uses (you said null?)
Advanced session plugin uses null, and it help you to avoid boilerplate codes and setup
I'm doing this all in C++, looks like ASP is just exposing stuff to BP?
Yes it's bp wrapper.
Yeah so ideally all i need to know is what i need to change in c++ to make this work
I'm not manually creating sessions anywhere here- maybe i need to do that?
It seems like you are very comfortable with c++, why not attach debugger and see the root cause.
ehh debugger wont tell me much i dont believe
honestly it comes down to a lack of understanding of the unreal multiplayer system i think for me
No it will tell, just put the breakpoint
And navigate
Put breakpoint in Login, PostLogin function of GameMode
And you would also see in which case that error warning is shown.
that warning is always shown when using standalone client/server
and postlogin doesn't fire, so im not sure how a breakpoint there would help
i suppose i could override prelogin/etc too and see how far it gets
okay well, i restarted my computer and postlogin is firing now...
thats odd
only time PostLogin doesn't fire is after Seamless Travel
as there is no logging in involved there
Implementation
Ty
FRootMotionSource_MoveToForce - Is there a way to maintain the velocity after rootmotion ends?
MoveToForce->FinishVelocityParams.SetVelocity = GetCharacterMovement()->Velocity; -?
I think this might do it - MoveToForce->FinishVelocityParams.Mode = ERootMotionFinishVelocityMode::MaintainLastRootMotionVelocity;
If you are using NULL OSS and not connected to same access point it will not work.
Which class is this?
that is terrible ๐ฆ
im having a hard time even imagining the intent
initial replication of members goes before BeginPlay @rich ridge
but we have no clue what NewVar even is
Ohh, good to know.
which has what relationship with the Actor running that code?
the client Actors call for BeginPlay comes from PostNetInit function
when spawning an Actor from replication
you still didn't even tell us what the problem is
whatever you intended to do with that code snippet, its the wrong way to go about it
you didn't tell us what its supposed to be doing, for clients or otherwise
and its intent is far from clear
What he meant is, what you want to achieve?
and what is the relationship between that Actor who runs that code and the CameraActor?
GetGameMode->GetNumPlayers->For (0 to NumPlayers - 1)->GetPlayerController[Index}->ClientSetViewTarget(ViewTarget)
is the least resource intensive way to go about it
where ClientSetViewTarget is a Client RPC event on your PC that takes input of type Actor that you need to make
that just calls the SetViewTarget on provided actor ref
close
first you need to reduce NumPlayers by 1
since the controllers are zero indexed
second, that will call setviewtarget on their server instances
to get clients to locally set them you send a client RPC
The GameMode only exists on the server. The client RPC will run the code on the client who owns the actor
Where is that BeginPlay?
What is the actual use case though? Are you just trying to set a newly joined player's camera view target to something in particular?
You can probably just have the PlayerController's beginplay check IsLocalController. If true, set the view target.
That way it only runs on the client with the view. It won't run on the server for anything except the listenserver's controller.
Not really sure how to help with that without seeing what you're doing.
What is the view target you're trying to set the view to? Is it just an actor placed in the level somewhere?
This is in your PlayerController class?
The one you want the view target to go to?
Or, which actor?
Try this. Leave the PlayerIndex at 0.
GetPlayerController0 will always return the local machine's controller in client, standalone, and Listenserver machines. But the second check will also make sure that this is viable for Dedicated servers too. You could get the same thing by first checking IsDedicatedServer->Not, and removing the branch check.
Should run for everyone, assuming that the Camera pointer is valid at that point. What do you mean by it changes for a while?
Delays really aren't the solve for the problem though. You should really find a way to get the camera locally to do the logic immediately. But some things really just require like a loading screen to hide stuff behind until it's ready.
is there any way to know during logout of gamemode if a playerstate is leaving?
because it is not null yet
@open quail For an intentional log out? You could always set a value on the playerstate before logout. I'm not really certain if there's a good way to handle blatant disconnects.
How can I start a session at game startup? I want a session to exist at main menu
just have an empty pre-first level that starts the session?
I have a function that moves a character on a spiral path by using polar coordinates and calling SetActorLocation, it's called on the server on Tick(), but it looks choppy, is there a way I could make it look smooth?
by choppy do you mean on clients? You need to run the same logic on clients to "predict" the actor's location if it's only being set on the server.
I see
@kindred widget what i ended up doing although not optimal is to check whether the playerstate has a pawn or not and if not i just ignore it
so BOXTRACES Complex trace doesnt work for complex collision right?
Or start the session as part of your menu begin play
If:
-I am on a server
-I multicast
-The multicast is not reliable
Is it still reliable for the server itself?
Whatever data you're multicasting should already be on the server
Hi @thin stratus.
Sorry to quote you but your website looks down (tested by me and someone else)... Is it really down ?
Your Compendium is the best multiplayer source i've seen, i'm pretty sad but i hope it's only temporary.
since you're multicasting from the server
Right, it is. So I would imagine that the call that arrives at the server itself, from the server, would always arrive, as it doesn't go through the network
Considering reliability has something to do with the bandwith saturation, I imagine...
But just wanted to be 100% sure
๐
no, the multicast is unreliable, if you have the server as the receiver of the MC then it is still an unreliable MC
before you can MC though, the server has to have the data
But if I am already at the server, how could it be dropped?
It doesn't have to go through the network
I honestly don't know enough about it to give a great answer, but de facto, if you are sending information from the server, you have the information on the server
you dont have to worry about a multicast to it
You're right, but my current logic is attached to be processed at the multicast event. That's why. Sure, indeed I could move it out though, and handle it seperately. Hence the question to be sure ๐
Can also confirm it isn't loading
Copy of Compedium while site is down
thanks @pallid canyon ! I'll save and archive this version, just in case ๐
np
We want to already have a session before menu shows up. I'll just do it at the splash screen/menu transition
Unless.... is there any way to fire up a session without having a hard load?
Yeah, I hard reset the droplet. Setting it back up over the weekend. Blog needs a new theme etc.
I'm calling it on the client too, it's slightly better, but still choppy https://imgur.com/a/44DRX7y
the launch is a RootMotionForce so it's okay
probably because the position is being reset by the server every network update, but by the time you receive those they're slightly in the past. Unfortunately there's no easy solution here - the way, for example, CMC works is that it doesn't actually apply server updates to movement immediately but instead interpolates to them over a short period based on how long ago the movement was.
I bet if you simulate lag (net pktlag 200 in console for 200ms of lag) you'll see it get much worse
What would be the approach to late-spawn a players pawn?
Basically, we want our main menu to transition into gameplay seamlessly. I dont know what pawn to give them until after gameplay start
Glad to know it's a planned maintenance, not an unexpected one ! Thanks โบ๏ธ
So i want to use the gameplay PC and Playerstate and gamemode etc, but not spawn the pawn and possess until later.
@twin juniper You need to send the vector through the RPC.
You play the input event on a client, and it gets it's value locally. And then you tell the server to do something with that same event's last input, which on the server will be zero, because it never ran on that actor in the server.
I wish I could find a tutorial on how to get witcher like movement while attacking. The only one I can find is really in-depth, but it is using someone's game framework and I am not really learning anything other than what options he uses to create certain behavior.
Which leaves me the only option of trying to reverse engineer (he provided his project for others to use) everything and figure out what the heck he is doing and why he did what he did
Click on the Event and add a parameter.
Not even really sure what you're trying to do. If you want to move a replicated object, do it on the server and let it replicate. And also do it on client separately, but let that get overwritten on the client. Predictive stuff can get semi complicated.
Physics replication is generally unreliable. With slow moving things, you can sort of work around it, but fast moving objects won't work. Only real way to do physics replication is to replicate position, rotation, linear and angular velocity. That's the easy part. The harder part is correctly setting it. For small differences, you want to only interp it a little closer to the actual location. For larger ones you'd want to override. It's the only way around the slightly random nature of physics movement.
@crystal crag you need to break down the problem into smaller pieces. it's not always easy but having an example project and a game to reference is as much as you could really hope for.
Why can't i set only owner see on my spotlight?
Does anyone know if Load Level Instance replicates automatically? Doesn't seem like it does, and I think Load Stream Level does. Do I need to manually load it on the client only if it is a level strreaming instance? Wouldn't that mean each Actor in the level is its own separate instance and cannot replicate/RPC between server/client?
any opinions on the best AWS service to save and load player save game objects (multiplayer)?
Anyone here happen to work on the Network Profiler and be able to tell if something is a bug?
How would I show a widget to all players through the game mode?
though gamemode by sending a Client RPC to each controller
best reserved for stuff like match summary widgets
I'm sending a character selection widget
you know their HUDs can just bring that up on BeginPlay?
Well, i'm having them bring the UI up each round
Like a CSGO round system then the buy phase will be a character customization screen
if its critical and can be triggered when players have been on the map for a while
yeah, have GameMode send a Client RPC each PlayerController
from blueprint you can pull GetNumPlayers from GameMode
reduce it by 1
then GetPlayerController[0 ... NumPlayers-1] in a for loop
to get all the PCs
@muted perch If it is a one off event that won't be spamed, you can use the gamestate to do a multicast RPC as well. Use a switch has authority node and place the widget code on remote only (if its a dedicated sever) or both if its a listen server
Here's a question - What's the difference between Network Smoothing Mode vs Linear in regards to a Character Movement Component's network settings?
My little racing kart game had a bit of a lag between the capsule (root component) and its mesh. Changing it from Exponential to Linear fixed it, but I'm not entirely sure why
well.. kinda fixed it.
Wouldn't you want that state driven?
OnRep in Gamestate.
@glad sedge Most of it is just math handling. The idea being that linear will correct and interp things in a straight, simple manner. Exponential would likely correct smaller errors less, and larger errors more. You can see some of the handling in C++ if you know it. There's quite a few checks, but a lot of the large handling seems to be in the two functions at the bottom of UCharacterMovementComponent::SmoothClientPosition
Ah right. I wonder if that's why I'm seeing a big difference between my capsule pulling forward when moving around.
At its worse, it looks like the capsule is dragging the mesh.
I'm also running this off my own PC, so maybe it works a little better on dedicated server (though I don't think it would.)
I'm building a lobby screen where players can select their avatar and loadout and such. I put these replicated variables in a custom PlayerState, and have the UMG widgets use the PlayerArray in the GameState to populate. If a client changes something, it RPCs the change to the server, which changes the replicated variable in the PlayerState, and then sends an RPC to each PlayerController that something has changed to they can update the UI.
The problem I have is that when that UI is updated, the PlayerState hasn't replicated yet so the new information isn't shown. If I put a Delay in the update method it does work, so the PlayerState does seem to be replicated properly. Of course a Delay is very unreliable for this, but I can't seem to find any OnRepNotify on when one of the player states in the PlayerArray has changed. I only see one in the Controller, but I need to know when the PlayerState of other players changed as well. Am I missing something?
@glad sedge Hard to say. Since it's a racing game, you may want to up the ranges a little too if you have faster speeds. CMC doesn't handle faster speeds at default settings.
The ranges being the Update Distance?
@craggy void I would suggest you populate your UI when player state is replicated.
And there is a function OnRep_PlayerState(), and it is called when PlayerState is replicated.
Yeah, that's what I'm aiming for, but what can I listen to to know when the state is replicated?
In the Controller you mean? I found that one. But what if one the PlayerStates of another player has changed?
Yeah. If you lower the NetworkMaxSmoothUpdateDistance a little. It should stick a little closer in it's smoothing updates. And keep NetworkNoSmoothUpdateDistance at a reasonable distance based on your highest speed to avoid as much snapping to the actual location.
You need multicast
One event to multiple players.
Ohh wait.
Basically you need to loop to all available PlayerState and set the observer.
Thanks @kindred widget I'll fiddle with it.
That's what I have currently, an UpdateUI sent to each player controller. I suppose I could add the entire player array to that multicast, but that just seems like sending it twice
And if your event is reliable, you will get callback for sure
I'm assuming the higher the value, the increased frequency for the packet update?
@craggy void Don't add entire PS array in event.
I don't think either of those have anything to do with actual networking. I think that they just affect how the client handles server's updates. Higher value on the first allows it to lag behind further. That's good for smooth interpolation, but bad for precision. Lowering it too much should likely cause some jittery feeling at times. Increasing it too much won't really have a huge adverse effect, but you'll see laggy movement at faster speeds. The second one just simply checks if the client is X distance from the server's last update. If so, snap it to that location cause it's considered too far to allow it to try and interp correct.
Set the observer? Is there something default for that? Or do you mean implementing a custom event on the PlayerState class that gets triggered by the PlayerState instance whenever one of its variables was replicated?
You need to set delegates for each replicatable variable
Yes exactly
What I do in my project is, I bind PlayerState to widget and bind observer to the replicate events
So basically, add a BluePrintCallable event to the PlayerState class, add an OnRep to each replicated variable in the PlayerState class, and call the event whenever one of the OnReps gets triggered.
And if a player connects or disconnects, multicast that to rebind the widgets
BlueprintImplementableEvent
I''ll give that a try
You got the core logic
Hello,
Again I would like ask for help on my steam connection issues, I keep having.
I have a basically working multiplayer project, but I cannot find the steam sessions, I start with my other computer (different steam acc, but same network). Finding them in LAN [without Steam] works.
Two questions beforehand, and sorry for being a dilettante. It's just so that there is no clear information anywhere on the internet on this and I have no inside knowledge of those p2p-connections are created with the help of steam:
-
Do I need to separately download and install the current steamworks sdk and copy those dll's into my unreal engine installation? I'm confused about this, because there already appears to be a steam sdk included with my unreal engine (4.25.4)
-
Do I need to forward certain ports in my NAT-router, when I want to start a listen-server in my local network? There is no info on this in the official unreal documentation, but I keep reading that this or that person claims, port 7777 (which I know can be configured) should be forwarded on the router.
Additional information: I use the advancedsession - plugin
hi, need help with nonseamless travel
i have this on my lobby gamemode (from where i travel)
and gamemode where i arrives
but i cant posses any pawn from my controller
doing this on start on gamemode (map where i travel to)
anyone know why I can't find my server's session when it's packaged but I can when it's in debug mode
If I run a Multicast event on servers GameState (not server RPC), does it call on all clients as well?
if you call them on server, yes
Should be back online.
This is my scenario:
In my game mode I declared a delegate like this
typedef TDelegate<void(uint8 RemainingPlayers)> FOnAlivePlayersChanged;
I call a custom function on game state called Initialize from the game mode which binds to this delegate with a multicast function like this:
MyGameMode->OnAlivePlayersChanged.BindUObject(this, &MyGameStateBase::Multicast_OnAlivePlayersChanged);
And the multicast function is like this:
void MyGameStateBase::Multicast_OnAlivePlayersChanged_Implementation(uint8 RemainingPlayers)
{
CurrentRemainingPlayers = RemainingPlayers;
}
For server CurrentRemainingPlayers is correct but for clients its always 0.
slightly curious why you are doing typedef TDelegate<void(uint8 RemainingPlayers)> FOnAlivePlayersChanged;
Instead of the old DECLARE_DELEGATE_OneParam macro
my question is why don't you just OnRep uint8 RemainingPlayers in GameState
Yes I could do that. But was just testing this method and wondering why is it not working.
likely cause your RemainingPlayers is always just 0
i don't see how that would be changed
No in server it is correct
as they would not yet have a replicated GameState Actor to handle the MC
but he is saying the clients are running the MC
but the value is 0
meaning the RPC sent a 0 value
ha, never saw unreal do that
The game state Initialize method is called from game modes InitGameState and the OnAlivePlayersChanged.ExecuteIfBound(AlivePlayers.Num()); is called from PostLogin in game mode.
with exception where it couldn't net serialize the payload
PostLogin is way to early
which is not the case here
for a MC
yeah, it is
Ahh then that might be the case.
So if I change to OnRep workflow will it solve the issue?
MC can fire before the rep happens
it will
Ok. So I'll try the OnRep workflow.
Usually when you spawn things and then RPC in the same frame, RPCs will almost ALWAYS reach the client before the replication of the actor does.
yes, your website is online, thanks !
Could you add a redirection from https://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf (which was our main link for your doc, pinned in at least 2 UE4 French discords and in many users favs) to the latest version please ?
The actual link (https://cedric-neukirchen.net/wp-content/uploads/2021/04/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf) would probably change for next versions, as it contains month/year in URL ?
Ah, I uploaded it through wordpress this time instead of manually into a folder. I can fix that though
does anyone know anything on my above questions?
create advance session and find advance session node is not showing.
I'm specifically asking whether I need to forward any particular ports on my nat router so my listern server session is visible online
@thin stratus btw, you forgot an "a" in URL in your text "I'm available for hire via https://saltypandstudios.com ! " ๐
and redirection you just added works fine, thanks man !!
If a variable has not changed since its last replication, will it still be replicated with the same value again or will it be skipped?
Steam will try to utilize NAT Punch Through but if your Server can't be found I would suggest trying to forward 7777 or the Port of your choice.
ok, thanks for the reply.
I configured forwarding the port 7777 (udp and tcp) to the server computer in my network, but it hasn't changed anything unfortunately. my online session is still not listed. I'm using the test-product id 480.
Afaik it should not.
Well 480 is overloaded as hell by all devs. Can be that you need to increase the amount of results.
Or get your own app id
increasing the max count to 50000 did not change anything either ๐ฆ
Steam will limit you long before that
To test properly you really need your own app ID
Thank you
i have checked the log of the second client pc though and there were some sessions listed that were discarded due to a different builduniqueid
certainly possible if they aren't using the same build
builduniqueid of server and client match, though
Yeah you get a lot of results
Which then fail to parse
That's why 480 is not useful for sessions tests
I know why i have saved myself this part up to the very end.
ok, thankyou all for your help
Yeah best to just get an AppID it doesn't take too long to setup
And you can actually test things like launching through steam etc then, makes distributing builds much easier
you should have got your steam setup a long time ago if you are near release
can take a good month
the review process, etc
@winged badger @meager spade Thank you for the help. The replicated workflow works ๐
does anyone work with photon in unreal?
lol pawns don't get destroyed when a player leaves the game in "4.27" ๐
well, some peoples will be happy
i think 3 of them asked how to do that in the last week
haha
should be easy to fix though
yeah, I'm stepping through it now
anyone can guide how to start learn multiplayer in unreal C++ ( not blueprints )
I wouldn't go with photon unless you have a specific reason to. Photon is/was bigger with Unity, but Unreal has a much better native network framework
so are you refers to replication in unreal ( native? )
yes, unreal's native networking
Hi there, I need to create an actor. When I call it on a client, it doesn't replicate. My guess is that I need to cast to something server-related, so what should I do?
spawn it on the server
How would I do this?
Depends where you are creating it. But just wrap your spawnactor in a if (HasAuthority())
And mark the actor to replicate
There is a HasAuthority node
So should I just check for that and that's it?
It's one of those questions where the answer should be simple, but to answer it, you need to know a bunch of other information.
Ah, I see
It doesn't spawn it at all now, I will try and find an authority checkbox on the player pawn
what is to the left in the graph?
What is calling this?
It has to be something that is called on the server
And I'm guessing you call shoot from input
Yup
I'm using advanced sessions btw
I would recommend doing some beginner networking tutorials
Ok, I will do that
the only things that is important in unreal multiplayer is how to RPC events correctly on client and server, can you explain what are the best practices for doing that? @jolly siren
because how i know when to use has authority node? and when to multicast events?
I would also recommend you doing some beginner networking tutorials
and when to mark a variable as replicated?
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...
Hello guys and welcome back to the Unreal Engine 4 Complete Guide To Multiplayer. In this video I want to explain what RPCs are, as well as the different types: On Server, Multicast, etc. I explain what the best practices for such and provide a example demonstration. In our next video I will cover the various multiplayer classes.
00:00 - 0:23 ...
I'm watching this one
Replication to keep state, Multicast for things that don't need to keep State.
Client RPC for specific client interactions, ServerRPC to let a client talk to the server.
can we create fully multiplayer game using only blueprints?
or we need C++
i mean playing game worldwide
not only local multiplayer
I wouldn't recommend it
Really depends on the game. C++ isn't necessary up to a particular point. But it will limit your ability to control bandwidth and optimize a lot of traffic.
i want to start with realtime multiplayer, since the games runs over internet
no ones play on same network
why we do that in unreal using blueprint and just basic finding sessions?
btw guys thanks for the help, really appreciate it
because there is not any concept or games that only support local multiplayer
we want to test and run game over internet
np roberto
so they said that we need to compile unreal from source to make dedicated server
and it take more time to compile the server
If you're just making a turn based game. Blueprint can handle it easily. Once you start talking about shooters, or more players than four to six, and considering other major systems and gameplay, Blueprint won't keep up.
It depends on the type of game you are making. Listen servers are an option
yes, i want to start with realtime multiplayer games, like racing, shooter etc that we saw in today most popular multiplayer games
To be fair. Even the turn based games I have in my head right now would greatly benefit from FastArrays.
i don't want to just learn blueprint with find session nodes with local multiplayer, this doesn't have any advantage
multiplayer means multiplayer ( not local multiplayer ), also does the find session, create session, and join session nodes work over internet?
yes sessions work over the internet if you use an online subsystem like steam
because the clients and companies want to make multiplayer games that everyone can play at any place
is there any alternative solution to test game without compiling the server from source?
you don't have to compile from source for listen servers
great, so does listen server also work over internet?
yes
from where i can find it's details of listen server
i mean is there any tutorials of listen server?
so that they test over internet?
in tutorials, everyone is making tutorials of local multiplayer, what is advantage of doing this in terms of multiplayer
@jolly siren so how steam subsystem works over internet? how players can join and find sessions over internet?
Look at ShooterGame, it's fully functional
is there only steam subsystem available? also can you list the all common subsystem are available for unreal?
can i test this game over internet? for example one person run game in US and other person run the game in Canada, does they both find each other using sessions?
yes
so it means that shooter game contains everything for learning purpose of listen server, right?
yes
Documentation for the C++ example game project ShooterGame
yep
is this game example of listen server or dedicated server, also may i ask question that does listen server is easy to implement and reliable or dedicated server
It supports both
Listen server is easier to setup
Dedicated server is more secure for competitive games but has cost
i already have download this project, how i can test over internet, should i need to create game build and share with my friends over internet for test?
yes, you will need to package the game and share with friends
thank you so much, i'm creating package, and testing, after i will see the source code how it works
i think this will clear all my questions about steam subsystem and listen server testing over internet
yeah shootergame is great for learning the basics. Good luck!
Hey, I'm having some trouble trying to get my damage overlay to work properly now that I have included RPCs.
My event, that is not replicated, for creating a damage vignette on the player screen:
It prints "fail"
And I have a "AnyDamage" event here as well, which automatically runs on the server as far as I am aware
This runs the hurt overlay.
Any ideas why?
@plush finch Is this for like showing floating damage numbers when something is hurt?
Nope, it is a simple blueprint widget that has a red vignette image
It gets added to the viewport if you are damaged
but apparently it is not valid
All widgets I add are now not valid in the player blueprint
except my hud
Well. I don't know why your widget is invalid moments after creating it. But you should probably be handling the widget's showing on the client, in an OnRep function for the health.
On server AnyDamage gets ran. You lower health. Short time later the server evaluates the health float and realizes it's changed and sends a new value to clients. Then on the client that owns the pawn where this has been lowered, you'd add your widget to screen there.
Hello! I couldn't solve my problem and want to ask again since it really slows down my progress:
Testing a multiplayer game in standalone mode results in a lot of lag - testing in editor windows is fine, can I do something about that? At the end clients connect to a dedicated server via matchmaking and I want to test that locally.
Thanks in advance!
@meager spade have you ever used gameplay tags to control movement and animation of the player character?
Similar to what this person is doing? https://www.youtube.com/watch?v=n6fxTki84_8
Video 1 out of 5
Goal is to setup a new character with locomotion and general inputs, including new animation pose for greatsword.
The first 5+ minutes are skipable ;)
The entire episode is not very exciting but I decided to do the ground work from zero instead of copy a 3rd person example or any other example character just to have more clean c...
not sure how well that scales in multiplayer
i have only one computer machine for testing game build, how i can test two executables of game build for testing multiplayer over internet
because i want to ensure that the game should work over internet
With steam, you can't I don't believe. I'm fairly sure you need two PCs and two steam accounts. Not sure about the default subsystem.
you can launch 2 standalones with same machine and same steam account iirc
hey guys, i have a weired issue with replication,
-- I spawn a new object on server, there are some replicated varibales in the object, whenever i change them on
server, they get replicated to client, I also save to my data base (another server) ,
-- next time when i log in, my another server sends me data of the last spawned object, then i spawn them on the server, everything works, but if i change the replicated on server, they do get replicated to the clients.
which is pretty strange, i cant seem to figure this out, any one ?
but if dont use replication and do multicast, that works
Hey @winged badger we talked about changing armor on a modular character before and how I want to avoid creating too many replicated actors. I made it so the armor isn't an Actor anymore, I just replicate a USkeletalMesh* on the charcater and it changes the mesh. But the armor still needs instance-specific data like Durability that changes during gameplay. Do you think that creating a new UObject* using NewObject() with just the instance data for the armor would work?
Making each piece of armor an actor would add a lot more replicated actors to the mix. An armor actor for pants, an armor actor for shirt, gloves, etc. But more generally, my problem is that I'm using data tables for my game items but they also need instance-specific data that changes during gameplay.
Why not use character for replicating the data and just load right armour on that data ?
The character is replicating USkeletalMesh* pointers, so I can change those and the player will change clothes properly. But I'm just trying to figure out where to put things like armor durability.
Everything visually is working great, but I need a place for the armor stats.
I have a data table set up for the armor. So I can put general data about the armor there. But something like durability changes during gameplay. So I only have static data about the armor right now.
Im trying to set a pitch variables for an aimoffset, but on the clients the head is just spazzing out all over the place. Anyone know what im doing wrong?
well durabilty seems like a property, that armour should hold by itself, but for that armour needs to be another object, which can hold data.
but you have this as a component, so i would make struct for armour piece, and replicate those,
struct can have :- USkeletalMesh pointer and stats.
you can have now array of that struct and can have multiple armour piece
I see what you are saying, just making it a struct that I replicate. I originally had the Armor as its own Actor with the stats and mesh. But some advised to limit the number of replicating actors that I have because it creates more work for the server.
@twin juniper multicast event will also get back to you, so if there would be change in values, that will make you go crazy ? i think you should print your local and server values, and see if there is any difference.
and you are setting this on server and then setting on multicast too, which means you setting it for local 3 times, and other two times.
it doesnt wokr at all if i dont set it on the multicast ive just been throwing sutuff around until it did something
@twin juniper I believe pitch is already replicated by default, so you can just use this in the anim blueprint of a replicated player
@sullen kernel you need to model your data for armour, make a struct for whatever you need in order to make it work. Ideally i would make USkeletalMesh as armour id (int). then use that, because client have data for everything you just need to tell them what to use, which you can do using some id too.
Worked thx
Most welcome. That'll be way more efficient than spamming multicast RPCs too
I need help understanding RPCs better if someone can help. So I have a client RPC on my character AShooterCharacter::ClientEmptyRPC and I want to call it in the character's AShooterCharacter::PossessedBy and this is what I have. ```cpp
void AShooterCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
ClientEmptyRPC();
}
void AShooterCharacter::ClientEmptyRPC_Implementation()
{
}```
Now. Can someone please explain why this screws up my gameplay code? I may just not understand client RPCs well enough but this seems really strange for me especially since it's an empty implementation. I figured I would be safe to do RPCs after PossessedBy since the ownership of the character is established (I think).
I should mention if I put the ClientEmptyRPC on the controller.... so ```cpp
void AShooterCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
ASSPlayerController* MyPlayerController = Cast<ASSPlayerController>(NewController);
MyPlayerController->ClientEmptyRPC();
}```If I do this way, then everything works fine for some reason but I need the RPC on the Character
I have to know something before starting the Login module of my website, will i be able to connect the players with Epic Online Services using my website database?
This might help
An overview of the role of the server in multiplayer.
Also this
Yeah I've read all that stuff before. I understand UE4's netowrking and ownership stuff. Nothing really explains my problem though
Hi can anyone help me at all trying to change another local player to a different character model. Thanks
Can i pull users informations from a cloud or web database to EOS (epic online service) features?
So you can't make an interface function RPC?
Hi, does the "reliable" property have any meaning when it comes to "run on server" func?
Yes. It's not specific to a flow of communication, rather how RPCs are handled.
So - I'm handling damage through an interface (I need more info than what the built-in damage function provides). I cast a line out to the target, check if it implements the interface and if it does, I'll then call the server fire/attack event. That then ends up calling the interface which will just call a multicast event in the BP that will replicate everything to the other clients.
This seems awfully convoluted - is this the standard approach with interfaces and networking?
What extra info do you need that the built-in damage doesn't provide?
Generally you want to multicast as little as possible, especially for things that happen often in the game like damage
Hit location for example
That should be in the DamageEvent being passed
But if you're multicasting to play things like hit reactions, you're probably better off with replicating a struct with your hit info, and playing the visual effects on the clients in an OnRep
I think we're talking about two different things.
When I do the damage event - I do pass everything I need, then I do the damage. It's just a simple health reduction right now and managing state (which will eventually be moved to an OnRep function).
I'm doing multicast for the time being to just get things workin' that's all.
No, I mean that if you listen to the TakeDamage event, there's a FDamageEvent struct being passed as a parameter, which contains things like hit location, damage type, damage amount, etc
If you're using C++ (or can at least read it if you're using BP), might be worth it to take a look at an example project like Tom Looman's surival game: https://github.com/tomlooman/EpicSurvivalGameSeries
I'm using BP for a pretty specific reason. AnyDamage is what exists - I see no TakeDamage event
And there is no struct that I see in AnyDamage
Hmm - point damage is probably what I should be using.
Sorry - I was reading about it
No worries. Hope it helps and make things a lot simpler to implement!
Yeah - I can get rid of this interface in particular, I know if the other actor doesn't implement the receive side, it does like nothing.
But my question still remains for interface methods. Because they can't be told to be RPC'd directly, is that the general flow? Just have it call a Run on Server event?
I can't say I use interfaces for anything replication related, but yeah - the interface method could call some Run on Server event (assuming it's being called from the client). Then set some replicated variable server side which has an OnRepNotify to warn clients about changes
If the interface is called server side you can skip the RPC altogether of course
Right right
i have a question, how should i update an actor, which is spawned on server and all the events are on the object. so owning client is null.
but object gets updated locally, then i use events on the object itself to update it, i was using the first player as owner, but i just find out, what would happen if player one leaves, then that object is without owner.
Is there an approach to do this kind of RPC to server ?
I am using Rep notified variables on object itself.
Seems like you're bypassing the built-in ownership logic of Unreal. Can you give more specific example of what this object is?
If you want to send RPC from client to server to control an object not owned by the player, then usually you would put the RPC on the PlayerController or the Pawn as that is guaranteed to be owned by the local client, and pass a pointer to the replicated object.
Hey guys, Im testing to connect over the local network with my computer as a listen server and a mobile as a client. After adding the right permission in Android Im able to connect from it. But no luck with iOS so far. It crashes when I attempt to connect. Is there any permission or something else that I could do? There is no relevant info in the crash log and also the debugger crash in a very odd place which does not really add info
Not sure if the channel is correct but I want to know if port can change if we sent multiple travel requests to a map (the ip is same but the port that is trying to connect changes)? Is it possible that this is an attack rather than my error on connection logic?
it does crashes in an objective-c file. OnlineSessionInterfaceIOS.cpp not sure what's going there, but it seems to fail in the constructor of MCPeerId
The player enter for a frame or two in the map though, I can see it in the server and also from the phone
Port shouldn't change from app startup time AFAIK. Game/Engine doesn't change it at any point anyway. If it did it would probably mess up a lot of server management software
Oh hey @chrome bay, didn't know you were on here. Just read your Better Burst Counter blog; good info! In case you were unaware: the two videos at the bottom of the article seem to be missing. Not that they're required to get the idea
Oh yeah I keep forgetting to go back and do that ๐
I can replicate only custom events in blueprints, and it cant return values, but how i supposed to make condition on server then? I want most of my events to be something like "try to do this", so server check everything important and then can successfully complete event or "tell" client that something was wrong so i can react locally to it.
you assume you can do it, send a server RPC to do it, then server sends an Ack/Fail back to client
that causes client to rollback if it gets a fail
well that is if he is doing prediction
simple answer is "ServerCheckSomething" then server does "ClientResponseToCheck" event
only way server can respond to a client question
@chrome bay Since you seem to be more experienced in networking efficiency; with the shootergame base for line traced weapons and hit detection, what would be best for multi-projectile (shotgun) weapons? I hacked it quickly by just looping over the ProcessInstantHit, but with 10 shots that will cause 10 RPCs per call, which I'm sure isn't the best. Storing the result of every linetrace in an array and RPCing that is the easiest way to improve that, or are there better ways with less overhead?
@craggy void batch them
pack all hit results in one RPC
or pack the seed and the first hit
you can send a const TArray<FHitResult>& just as easily as const FHitResult&
and reproduce
also you probably don't even need to send the full hit result, you rarely need the whole thing
just what you hit and where is (usually) enough
Yeah, I meant the ServerNotifyHit/ServerNotifyMiss RPCs
you don't need 2 of them
ShooterGame has 2 tho, and its ok for single line trace weapon
ShooterGames' weapon stuff isn't that great tbh
It has another reliable for the state machine too which is kind of not really needed
the notify miss i feel is kinda pointless
yeah defo
if i as a client detect i have not hit anything, why does the server even care?
they do all kinda of unspeakable things in example codes
you might want to display the shot visually
Hmm, so pack the hit results of a single shot in an array and RPC that. And for replicating displaying missed shots just use the burst counter (with a timer for automatic weapons)?
long time since i looked at shootergame
yeah actually I think that's why they do it IIRC..
@craggy void dont pack hitresult directly
It's been a while ๐
make your own custom smaller set of data
Yeah, the ServerNotifyMiss is to replicate visual effects
hll is based on it but we've changed sooo much
then again FHitResult might be quite optimized
in its Serializer, again, would need to clarify
@chrome bay what do you do for traces on your projectile manager?
But good to know, thanks, gives me something to work on
One reliable for each actual shot, and one reliable if we hit something that needs to be verified (like character etc.). We have to split it up because the traces are projectiles so not necessarily same-frame hits
FHitResult is an excellent example of how to write a NetSerialize
same as Fortnite, one RPC per shot
really elegantly done
are you strictly projectile or mix?
projectile in all cases now (when i say projectile i mean a stepped trace but you know what i mean)
or you fake projectile with a hitscan (aka Zlo's system)
As i understand that, you need 2 events, first that will be called on server and second that called (inside first event) from server to client with response?
So then object must know what object called that event to response back to that object? I want it to be flexable, so any object can use event, but i guess its impossible in that case?
he can't do that with WWI game
yeah it's just a bit of data rather than actor or anything, but it is "simulated" over several frames
so you can have like bullet drop and travel time
but without needing an actual projectile actor
so the clients do their own frame by frame trace for their shots and RPC hits to server, server just verifies?
yeah travel time was the hard one.. design really had to fight me for that :d
in fortnite they use mainly hitscan, but the snipers are a projectile actor o_0
i wonder why they didn't do it without projectile actor..
we actually simulate the shot on both because we have a "suppression" system as well which the server has to apply, so client + server simulate the projectile, then if the client sends a "pls verify" RPC the server resimulates it from the start point to check for wallhacks etc.
and we keep a short little buffer of "recent" shots so if they try to send a verify for something wayy in the past we just ignore it
(or kick em)
I wonder if it's just easier if they don't have very many?
yeah likely
I have a problem that when I attach an actor to another actor on server on remote client it sends the actor somewhere far for a moment, then returns back and keeps replicating. I am using smooth sync plugin, and I tried disabling it and when attaching of actor to actor happened it started replicating even though the smooth sync component was disabled.
Is there really no easy out of the box way to detect when the GameState's PlayerArray has been replicated? Everything I've seen so far looks very convoluted and error prone. I've been fiddling with this for my lobby for a day or two and I'm really considering just making my own Array and replicating that with OnRep to use in the UI. It's not like a lobby will have high bandwidth or timing requirements anyway
It doesn't actually replicate if you check it out
The array is reconstructed locally when player states replicate, the AddPlayerState and RemovePlayerState functions are virtual so you can add an event which you broadcast there
Since the player states themselves are always relevant, they can just add themselves to a register locally. Saves the non-negligible overhead of replicating an array
Yeah, I noticed those. I already gave the AddPlayerState/RemovePlayerState overrides with an event a try, but I guess something else was off somewhere
I guess the problem was that the player state was added, but wouldn't be replicated yet. I'll just clean up what I have now and give it another go
Ah that can never be the case because the player state is what adds itself to that array
So there shouldn't ever be any null entries
Don't forget about initialization ordering issues too, the UI will need to query the current state of the array when it's first created - otherwise it won't be up-to-date until another player is added/removed and the event is broadcast.
The AddPlayerState adds it to the array I would assume? So if I call my event after the Super::AddPlayerState it should be in right?
Oh, not null, just the default/outdated values
What holds the data and simulates in this system? A Subsystem?
I'm using framewise traces for projectiles but it's still 1 actor per projectile. My projectiles are all easily visible
yeah a world subsystem
we just use particles for the visuals, which is good enough as it's all just bullets. It's not as designer-friendly like a projectile is ofc, the implementation has to be fully CPP unlike an actor
yeah
How do you do the particles? That's the part I got stuck on, since the options are either a global particle system or you're back to 1 bullet = 1 actor
We just spawn them via UGameplayStatics::SpawnEmitterAtLocation() when initializing the bullet/projectile
The data has a TWeakObjectPtr to the UWorld, the "simulator" class etc.
In my multiplayer project, I have an actor A, whose owner is B, and B's owner is player controller. When I call GetOwner in blueprints in actor A, will it give me B or player controller?
so it will give me B, got it thanks!
does anyone know how i could implement a rocket jump mechanic?
would it have to be through the character movement component?
@craggy void Thanks for highlighting about the more specific damage events (I only ever really bothered typing in Any Damage to be honest) - I switched everything over, still works, and it made me go ahead and switch to the OnRep setup like I was planning to do, just sooner.
Most welcome!
https://docs.unrealengine.com/en-US/BlueprintAPI/Pawn/Components/CharacterMovement/AddImpulse/index.html
Probably with that
Add Impulse
i tried that but it only did on the server not for the clients
Hmm, was it Launch Character then? Did you try that one?
https://docs.unrealengine.com/en-US/BlueprintAPI/Character/LaunchCharacter/index.html
Launch Character
yeah i did it was the same
its confusing me.
because its replicating the server to the client but when i try to run it on the client it doesn't work
You probably need to call it on the server. I'll see if I can hook it up quick
is there a way to force it to run on the server
I thought stuff like that was unreliable?
Maybe I misunderstood what someone was telling me
Well, if it's a rocket jump, I assume you want to launch the player from an explosion. As you want to do the explosion handling server side anyway for the damage, just handle the launching at the server side too
What part? The RPC or the launching?
The launching
I can imagine that lag could create some issues with syncing the movement
The has auhtority is useless as input is client side
Unless it's a listen server
thats still a locally controlled pawn
controller/pawn w/e
and you still don't need HasAuthority on the input.
a server calling a Run on server event will just execute it locally
like a normal function
Ah like that, got it
That's what you get from looking at ShooterGame too long with it's StartFire() { if (no authority) { ServerStartFire(); } // Do shooting logic} and ServerStartFire() { StartFire(); } chains I guess ๐
thank you
Since sets and maps cannot be replicated, can they be sent using RPCs?
Is there some sort of global event broadcast system that I can use for broadcasting things, such as footsteps, so that other characters can be aware of those footsteps? I can't use delegates, as I don't want chars to have to re-bind to every character that joins the game
@eternal briar no
you will have to bind at some point somewhere.
for footsteps we just use Anim Notifies
they fire on every client when the animation plays.
@lucid vault ^
I have that system set up so that my character BP is notified
When my character runs, I want each footstep to notify other characters so that they can play a camera shake
However, I don't the running character to directly modify nearby character's cameras. That seems pretty anti pattern to me. What if, perhaps, there are two characters running, both trying to modify another characters camera at the same time
I would prefer if there was a system in which I could broadcast the footstep from one character, and the global footstep event could be listened to by other characters
Im trying to add an item pickup system to my game. I am calling the interact interface function locally so i can display the loot notification on just that player and then im calling the set visibility on the server, but it doesnt seem to set the visibility when the clients do it. Does anyone know what I'm doing wrong?
PlayWorldCameraShake?
hello, can anyone help me with my Problem? My Problem is that i made a dedicated server (from source) and my friends cannot connect to it. I made the Port Forwarding (with my IPv4 Adresse and Port 7777 which my server is also using) and i also made a firewall input rule for that Port. I can join at my machine lokal. But if my friend tries to join using my IP at the command tab nothings happens and i saw nothing happening at the log.
so like i made something where u can set the players color to whatever you want, everything works as far as im concerned and it "technically" replicates properly
the issue is is that the color does not show up for a new client apon joining, however if i press a button to call it again it works and the color shows up for the client(s)
Are you using a RepNotify property for the Color and setting whatever is visualizing the Color in the RepNotify function?
Hey! I was having trouble using seamless travel when trying to reopen a level using the ServerTravel console command. When I have seamless travel disabled the players will always spawn in. However, when using seamless travel the players sometimes don't spawn in (all of them)
I was hoping to get seamless travel to work because to my understanding using it allows players to not need to reconnect to the server
I've been having trouble finding documentation so if anyone can point me in the right direction I'd really appreciate it :)
I'm not sure if this a bug with just the PIE ^ but here's my settings for it:
What do you mean they dont "spawn in"?
How are you spawning them, what does this mean exactly for your game.
The Image you posted has nothing to do with Seamless Travel nor Spawning.
Oop you're right I should've been more clear. I'm spawning them using the default playerstart. I'll record a short video real quick and elaborate more
Thats where your spawning them, not how.
Are you simply setting the DefaultPawnClass in the GameMode and letting it spawn that automatically?
Yes, I'm not overriding anything having to do with spawning them in
It's the same one. When using seamless travel will it not 'recreate' the level?
I'm not sure how to phrase that
I was using the same level for testing it out
If your using ServerTravel it will yes.
It will recreate the level?
It restarts it
Your not doing anything on PostLogin in the GameMode?
This does not get called for traveling clients for Seamless Travel.
The only thing I'm doing on postlogin is setting the player's name in the player state
Other than that I'm not
How do you know they arent being spawned in correctly?
Oh
I press the F key on my keyboard and it sends a server RCP up to the game mode telling it's ready to restart
Seamless Travel doesnt work in PIE
oh shoot
Is this something I should just roll with and wait until I push it out to AWS to test?
You can test it locally if you run the dedicated server locally and connect to it locally etc
But has to be outside of the Editor
That's good though- I thought I had a misunderstanding of the framework
You can typically trust Seamless Travel to work though.
the color variable is replicated
Hello. Quick question about dedicated servers. Say I want to spin up my own servers for testing using my other PC (i6700k 16gb ram) how would I go about creating options for different game modes. Like if ppl just wanted to play Deathmatch on a map, or Bomb on another, how would I make that happen? Is it possible to have some form of UMG widget on my server builds# that allows me to set the settings for each server I instantiate? How many servers can I run at once for a 5v5 competitive shooter?
if your server has a static purpose you can use different startup arguments to setup what ever you want.
You also could create a server that is just responsible for match making and that is capable of spawning new servers with the correct setup on demand.
How many servers you can run fairly depends on your implementation^^
when an object is first replicated to a client, are all of its replicated variables immediately replicated as well? i have a boolean that OnRep initializes the object for the client, and want to know if the other variables will be set when this OnRep fires or not
adding side question to discussion above.. so 'run as client' option does not run dedicated server in background?
There's an open source plugin that does loose coupling: https://github.com/getnamo/global-event-system-ue4
well, since its BeginPlay
at least some instances won't be owned by the client with more then 1 client
I had a quick question about using seamless travel. When I open a new level using seamless travel what exactly moves over? Is it just the pawn/player state?
Lets say in one level I have a pawn with GameMode A with a player controller A. When I move levels, there's a different GameMode, B, with player controller B. Does the pawn use this new player controller?
Thanks :)
Pawns don't come accross
No actor is actually transferred, the engine spawns new ones and gives you a chance to copy properties between them before destroying the old ones.
By default only the PlayerState has any transfer functionality
you can persist them
Ah, that's perfect actually
by overriding the GetSeamlessTravelActorList in PlayerController
to include its own Pawn
I'm trying to create a lobby system and was worried I had to spawn the pawns in the lobby before travelling to a new level
So the only thing that persists would be the player state?
Does it actually change the outer of the pawn to be the new level?
spawned the pawns so player can see the pawn while getting setup
@chrome bay i think the PC remains as its link
its been 3 years since i used persising the Pawns, so don't recall
@elder crypt out flow is pretty much
i spawn preview pawns (not gameplay class) in lobby
players get setup, the lobby and combat PS share a base that has all the info transferred between levels
lobby and combat don't have the same GM, GS, PS, Controller, HUD or Pawn classes
@twin juniper Client has to own the actor, simple as that
That clears a lot up, thanks!
base PS implements copy properties to copy all its data from old PS
It's hard fumbling through this for the first time because I have a lot of trouble finding documentation
then when i land on combat level i pull the data from it to instantiate the Pawn
or better phrased, configure the Pawn, as i don't have different gameplay classes for different hero classes, all composition
we do persist one Actor, MisisonSetupActor both ways lobby<=>combat
it keeps all the mission settings and results
@elder crypt i also suggest configuring the travel level to have the same GM as departing (lobby) level
What would be the advantage of that?
Either spawn it on the Server with a valid player as the "Owner", or call SetOwner(SomePlayer) on the Server.
thats avoiding disadvangates of not doing it
Spawning it is really the only reliable option if you want to call a server RPC on begin play
as the Travel level will execute GetSeamlessTravelActor list with its own GM
so if you don't set it, and are using an override of that function
and @twin juniper you should read into this http://cedric-neukirchen.net/2017/02/14/multiplayer-network-compendium/ . You need to make sure that whatever is calling that function is the owning client (autonomous proxy)
your Actors won't survive transfer from Travel to Combat
oop
It should be the second link in the pinned channel
And thank you!
I'll look into implementing something like that- I really appreciate it. I'm doing a small-scale golf game
try that
You'll want to read all of it but the Remote Procedure Calls chapter (page 59) goes in depth on what you're dealing with
Chances of someone trying to access that compendium the second I restart the Droplet to resize it due to out of RAM issues..... too damn high apparently.
Updated that pinned post. Compendium sits on the homepage now.
Need to update that eventually to have a proper image or so
While that is horrible it should work most of the time I guess ๐
The problem you've got with actors placed in levels is they almost certainly will begin play before player pawns are even spawned.
This matters a lot more in multiplayer
You then have the issue whereby if the client doesn't receive both the actor, their pawn and the change in ownership before that timer expires, they also won't call the RPC - so there's an inherent replication race condition there too
^ Each player, including the server, is running their own instance of the game independently
Oh yeah, didn't even see that
That's the tough part and necessity of replication- to keep things in sync between these instances
To get MP stable/reliable you need to build in a lot of redundancy to deal with stuff like this, and all the "what if" scenarios
Hard to know/teach those though.. just comes with exp
What worked really well for me was to sit down and write everything down in Cedric's network compendium in a journal
If it's a Blueprint placed in the world it's not something you can do reliably in that one Blueprint alone
Best way to handle this is spawn the actor on the Server, with the correct owner
What's the timer being used for?
that is also a limitation of blueprints
which are somewhat inadequate for networking
proper solution is for server to assign owner to preplaced actor
then OnRep_Owner in that actor (checking if owner is locally controller) would be the first time you can send a RPC
You should do that in the gamemode then
It's only on the server so you don't really need to worry too much about replication for that class specifically
@twin juniper i generally advise people not to jump into multiplayer before they are very comfortable with unreal in general
usually just leads to frustration to the point of quitting unreal completely
I agree. Check my logs and you can see that the first thing I tried in Unreal was networking
It didn't end well and it took me a few years until I approached it again
Reading into the singleplayer framework and getting a grasp of that helps a long way:)
i can tell from your code snippets that you are not even close to fully understanding the game flow
๐ฆ
Something I was trying to conceptualize was how to determine when every player was loaded into the new level. There doesn't seem to be an easy event out of the box for it. I kinda just checked if the NumTravellingPlayers was 0. Is that how you approached it?
@elder crypt it gets more interesting when you have a shitton of stuff to do before you allow BeginPlay to be called
ahah, I can imagine
we spawn a procedurally created level -30k or so actors
on each machine separately, then lie to the engine in order to network them after the fact
I'm assuming BeginPlay is called regardless of whether or not the MatchState is set to in progress < for the pawns
goodness that's a lot. What game are you making?
linked in private
to top if off, most of the levels are destructable, and we allow join in progress
client has no business determining win/loss for server to verify
server on its own, tracks win/loss conditions
from the GameMode
then just notifies the client the match is done
think of the client as just a keyboard/mouse
Hey guys any resources on how to have in game notifications for steam invites ?
bind to a callback from steam API, shove the handler on the Game Thread
and display a widget for it
Via steam sockets ?
Is there any work around to this issue ?
https://answers.unrealengine.com/questions/328659/change-skeletal-mesh-blueprint-multiplayer.html
Thanks, have you tested it before ?
Thanks ๐
StaticMeshComponent has the mesh replicated so so long as the component is replicated it should work fine, but it's still a less-optimal way of doing it
๐ try it in a MP game
USceneComponent has a bunch of built-in replicated properties too, and when you enable replication on the characters' USkeletalMeshComponent it breaks CMC networking too
It works fine, used it loads of times
You really should avoid replicating USceneComponent derivatives if you can
Ok, not arguing it...i know i experienced the same issue just 3 weeks ago in 4.26 with staticmeshes not replicating on runtime to clients
When you change them during play...
yea, i am in that right now
Rememeber that both the actor and the component has to be replicated
(And you should only call SetStaticMesh on server ofc)
I'm in 4.25 atm but I don't think they removed it from 4.26
Same happened to particles changed during play. And yeah im aware of component replication and actor replication. Not new to ue4
That's in 4.25
The solution to use onrep replication function to do it was perfect solution for that headache
Yeah that's the way to do it
I reported it to epic but they never got back to me then someone replied it was a known issue
thanks both of you !
Now I think of it the onrep function is probably the best way to do it. Because even if it was replicated anyone that joins after the mesh was changed ain't going to see the correct mesh
Unless you're doing it through the onrep function
Is there a way to not have the player controller persist when using ServerTravel?
Is there a way to automagically start a session at startup or do I have to do it at the splash screen/main menu transition?
Oh it seems I might be able to use OnSwapPlayerController somehow
Hi guys, often while testing multiplayer I get a black screen on the client. The only thing that fixes it is rebooting my computer. Has anybody seen anything like this before or know what may be causing it? Thanks in advance for any info, you'd be saving me a lot of time.
being kicked to an empty entry/transition map perhaps? Would have to check logs
Is there anywhere to learn this or see a simple walk through. Everything Iโve found is about AWS not a custom solution. I want to start out cheap and if my game demands it then try to go for the big money servers
can't get cheaper than listen servers
It pays to try and support listen and dedicated the best you can, even if you don't ship with it
The only bug I'm aware of which the engine cannot detect that crashes a computer is an infinite loop triggered by actor spawns. So like...Actor A spawns Actor B, who spawns Actor A, etc
well you could have a look at kubernetes and agones. But this could be a bit overkill, depending on what you want to do^^
If you don't need lots of servers for now, especially not dynamically spawned, prespawn what you need with cmd args.
if you need them dynamically, well, then you need some sort of match making and a system to dynamically spawn servers^^
Thanks for the response. I don't think that's the problem. It's not crashing for starters, it's just a blank screen on begin play. When I restart my computer it behaves as expected.
a blank screen can mean you're not in a level, or you dont have a possessed pawn
Most likely you've had a network error and you haven't handled it to send you back to the main menu
yes, I believe that could be it. Will continue to investigate.
I'm not using a menu, just a sandbox project to build a functional ability system
pretty bare bones
The engine will kick you back to the entry map on error IIRC by default
If you don't have one set it probably sends you to the blank "Untitled" map
It will
I haven't noticed anything like this ...
On looking again, I see this error: "LogNet: ReplicationDriverClass is null! Not using ReplicationDriver."
Will restart my computer and try again and see if this error repeats. Thanks again.
Real talk - thanks to all of you Networking vets who stick around and answer the same questions time and time again. Ya'll the real MVPs.
Is there a trick to automagically launch as listen?
Basically I want it to be seamless, you hit the main menu as a listen server
add the ?listen to the launch params or have a empty default map that opens MainMenu with the ?listen param
When using seamless travel with two different playercontrollers between levels the player doesn't seem to want to spawn in the new level. Does anyone know why this may be? I'm spawning them automatically through the DefaultPawnClass in the GameModes
SwapPlayerControllers() looks like it's doing what it should do but the player seems to not want to spawn
Does it make any sense to make the method MoveForward(float Value)(and similar) to an RPC in case that the code looks like this ?
void UPlayerMovementComponent::MoveForward(float Value)
{
if(Value != 0.f)
{
M_OwningPlayer->AddMovementInput(M_OwningPlayer->GetActorForwardVector(), Value);
}
}
Where M_OwningPlayer is an ACharacter ?
CMC does that for you
Alrighty
Hello everyone, I'm having a few issues working in Source with GameLift enabled. They are:
- *Server.Target.cs does not populate to */Source folder in the solution explorer after generating project files
- After manually adding *Server.Target.cs, building with the Development_Server x64 build config (after rebuilding the editor) builds as "Invalid Win32" instead, and "Development_Server" is not on the list in the config manager
- as a result of one or both of these I am unable to build my server application
Hey guys would this: https://docs.unrealengine.com/en-US/API/Runtime/Engine/GameFramework/GetPlayerControllerFromNetId/index.html be useful to get the player controller from the UniqueNetId ?
Returns the player controller associated with this net id
that is what it is for
damn ok I have to expose this in Blueprint then
that kind of PC access sounds fishy to me
I've cooked a build, how do I use the command line to start one instance as a listen server and the other to join it... https://docs.unrealengine.com/en-US/InteractiveExperiences/Networking/Server/index.html
They list it there but I'm not sure how to apply that to my exe
An overview of the role of the server in multiplayer.
Is it just -?listen to the shortcut?
Will the "find sessions" node always fail within the editor?
If a timer needs to run on the server for game logic, how should it be replicated back to client to update UI?
If client starts its own local timer, it won't be in sync with the timer on the server so what the UI is showing could be incorrect.
I want the UI to show a progress bar that should be filled up 100% when the timer is fired.
For now I am going to have the server start the timer, send a client RPC telling the client to start its local timer. So at least if its wrong, it will finish sooner than expected for the client. But if there's a better way to handle this sorta thing, please let me know. ๐
How difficult would it be to make a simple android client that uses a widget interface and then trigger events from that onto a full-fledged PC client - I've got the listen server working
uh, this is an in built node lmao
i dont have the advanced session plugin rn i dont think??
Yeah I checked, it's built in, also I fixed my erro
I'm confused AF here - I am starting a listen server but how I open two instances of the same exe - it keeps closing one and opening a new one, so I can't open one, execute a console command to ?Listen and then open the local IP to join it - I asked earlier but no one seemed to know
Copy your project, run the exe in the two different projwcts
ugh - it's a 30 gig project
Don't use clone either
Hehe that's why Im doing all the server work first and dealing with making the actual project later lmaoo
i can open 2 copies of the game..
I can on my computer here but on a machine with VR it doesn't
seems a limitation with the VR
that's why I was asking about shortcut launch options
like having the windows shortcut could I pass in a console command there?
Tf, that's not normal I don't think, even the original ue4 multiplayer project couldn't do it cuz ue4 in built anti cheat
it is normal ๐
make a new project, cook, run the exe twice
Doesn't matter regardless
like can I pass anything parameter in there?
to do what?
Oh after cooking, I mean just for testing
well you should cook for testing
I don't do that, waste of time for me ๐คท
Editor testing != cooked testing
Ik it's good practice though
I just use the standalone feature by launching it from files
@merry hemlock i mean what do you want to pass in? to do what?
@shy kelp our build server just does the builds periodically, its a time saver ๐
I'm new to multiplayer though I read the replication compendium 2 years ago - I am just checking down this rabbit hole superfast - Because it may not even work so I don't want to have to spend that much time double checking
but I just want to be able to open up a listen server and a single other client - it's mainly to use the second client as an interface for the instructor in a VR training program
and basically my begin play just as a widget to the viewport only if you are not the server (the server is the VR player in this case)
before I can begin to iterate anything, I first have to have it running as a package to build because the way the editor handles VR previews I can't do it any other way
@meager spade Now that I have this package billed I was looking for a way to run some of these commands - unable to do that on my local machine here, but when I remote into my other machine that actually has the VR running on it (it's many miles away in another office) - when I tried to open up the EXE, and open up the main level with the ?Listen - When I tried to open up the exceed again so I can use the open IP command it just closes the other one it opens up a new instance
Is the replication graph on by default now for the grid based culling? Even for blueprint projects - or is it manually turned on
@twin juniper In the game mode you can add the players to an array as they join, do the clients need the info or just the server?
In the game state I believe there is the players array, which tracks player controllers to the server as well
Get GameState -> Get Player Array
if you want to avoid the local player, you can get the controller from the playerstate and not add it if its LocallyControlled.
@merry hemlock i have no idea, why you trying to open them on the same machine tho?
i mean wouldn't the "instructor" be on another machine?
No, then I have to make fire depts buy more computers
again, there is only a widget on it so it shouldn't be too intense, and these are beefy machines
goddamnit why does the editor keep opening up and closing another
It's VR being an asshole again
i swear to god I've spent literally over 2,000 hours trying to get a instructor interview working in VR in the unreal engine - using a stupid 2DRender target assigned to a 3dwidget via scene-cap component, and setting the spectatorscreen texture to that and interpolating mouse movement to the widget interaction component - then an unreal web server and making an entire list of commands via html/CSS jscript bullshit, before finding out that the plugin has massive GC memory leaks, then I spent another 500 trying get the spectator screen plugin to work, only to find out that it interrupts critical input and breaks my game --- now I see light at the end of the tunnel using a multiplayer client, an a crude test indicates it COULD ACTUALLY WORK, and now I can't open up another instance of the game on m VR machine so there is no way to confirm it, I will literally have to sink in a day's work learning multiplayer concepts only to find out, I'm sure, that VR is different in Unreal and fuck me for trying to do it .
well PlayerArray is PlayerStates
so your == there will not work.
and construct is going to be way to early
if the widget comes up instantly
put a 1 second delay
pull the blue node from the foreach, get owner and then compare
Owner of playerstate is the controller.
No
Before the foreach
And you equal is wrong also
Read what I said
I was wondering if anyone knew of a good course/resource to get a grasp of UE4 with AWS's Gamelift. I watched through and followed along with Flopperam's YT course but I'm having trouble finding other resources to learn from. Thanks :)
I told you the way to get players. So don't say I don't know what I am saying. I have been using ue4 professionally for 3 years on multiplayer games. @twin juniper
For all I know the rest of your logic/setup could be wrong. You asked how get the players. I told you. If it's not working then try debugging.
@meager spade does ue4 support P2P or is it client server only
Huh, all players have a player index?
Its sever client only
Either listen server or dedicated server
People have done p2p but it's not default in ue4
damn
hello im just up at 3am to say multiplayer is such a headache. โจ
@vast forum check the logs, do you see anything like "No Owning Connection for ###"
And presumably myThing is an Actor / Actor Component class?
Yeah, so I did notice one log which I was quite worried about. Let me pull it up..
failed to send ping over the network, reason: The connection has been aborted.
The actual structure is:
AMyActor which contains some internal UMyObject.
UMyObject needs to run some logic client-side, then send a notification to the server, so it can authoritatively do some things.
So I'm calling myObject->GetMyActor()->CallServerRPC().
For maximum safety, I've actually gotten GetMyActor into a variable, so I can fully check that its not nullptr in the debugger before calling CallServerRPC
The RPC itself is:
UFUNCTION(Server, WithValidation, Reliable, BlueprintCallable, BlueprintAuthorityOnly)
So my understanding is that after my breakpoint on myObject->GetMyActor()->CallServerRPC(), I will next hit a breakpoint in CallServerRPC_Implementation, but thats the part that never happens.
The whole structure of CallServerRPC is not something I've written myself -I'm only attempting to call it.
Yeah that's fine, the CallServerRPC() body is implemented by UHT so you don't need to do anything
But _Implementation not being called means it's never reaching the server
So the first thing to be sure of is that the Actor is owned by the clients' player controller, either directly or through it's pawn or something it already owns.
If it's not you won't be able to call those RPCs
Also, what do you have in the CallServerRPC_Validate portion?
If that returns false, it will kick the client and the _Implementation will never be executed either.
Yeah I'm aware of the validation trap. Its just returning true (not sure why it needs validation in that case, but maybe future-proofing).
If you don't need it you can remove it, they made it optional now (just remove WithValidation from the UFUNCTION)
So the first thing to be sure of is that the Actor is owned by the clients' player controller, either directly or through it's pawn or something it already owns.
This is something I definitely need to look into, and would probably explain it.
Yeah that's the most likely scenario
To call a ServerRPC the player has to be the net owner of the actor, which you can set by calling SetOwner(SomePlayer) on the Server
Ok. All good things to google, thank you.
How does that work in reference to shared actors?
TL;DR it doesn't, clients can't call RPC's on an actor they don't own and that's by design
To get around it, you usually have to route the RPC through something they do own - e.g. a controller
If you have a lot of in-world objects that clients need to call RPCs on, it can be beneficial to setup an interaction system to handle that more generally
I see.
Looks like I need to do some more investigation internally then. Thank you very much Jambax.