#multiplayer
1 messages Β· Page 582 of 1
@kindred widget
A player state is moved to an array of inactive player states when disconnecting. It remains there for a few mins (duration can be specified in the gamemode I think)
You can override the copyProperties method on your playerstate to override what is "saved"
The player id copied by default I think.
Best example off the top of my head is ARK. Player logs out and their body drops on the ground, stays there for hours, they log back in and repossess same body. Is that something I do based on the PlayerID?
I have no idea how ark works, but I would not use that for a long duration like that.
It would "work", but create further problems since you still have to deal with the case that the playerstate was wiped because even a longer timeout was exceeded.
If a server is restarted that array is cleared or if the player joins a different server that one does not know about the player at all
@twin juniper if the host disconnects it'll be handled like a network error
Which you would usually show a dialog box for like "you disconnected"
From a UX standpoint, probs don't want that
@chrome bay Even though I implemented OnSessionDestroy and sent the client back to the menu map. The client still crashes if the host disconnects.
Am I doing it wrong?
if(Result){
UGameplayStatics::OpenLevel(GetWorld(),"/Game/ThirdPersonCPP/Maps/Menu",true);
}
}
I get that the Playerstate gets wiped. I don't care about the PlayerState. I care about that specific PlayerID that is supposedly populated by the OnlineSystem you're using, like say Steam. When the player logs in and the new PlayerState is created, and that PlayerID is created, is the PlayerID repopulated with the same ID based on their online system's profile?
Can I use PlayerID in the PlayerState to get information from the server's save files, and from Actors to identify what is that specific player's stuff in the game based on their online system login?
There is also the UniqueNetId. That one seems to be one you want
@kindred widget in case of AiCharacters, when server spawns it , the login and post login functions are not called.
So does it matter.
Who said anything about AICharacters?
I thought you were talking about my use case. Sorry my bad
Does anyone know how steam sockets are supposed to work with dedicated servers?
I thought one big benefit is that the steam SendP2PPacket method is used which works using steam ids and channels instead of IPs and ports.
My dedicated server is listed in the steam masterserver list, but it also shows the ip, which makes no sense to me ("addr":"17x.13x.x.5x:27015","gameport":7777).
The netdriver seems to have started without any problems, so I wonder if I made a mistake somewhere...
LogSteamSocketsAPI: Verbose: SteamSockets API: Log RelayNetWorkStatus: avail=OK config=OK anyrelay=OK (OK)
LogNet: GameNetDriver SteamSocketsNetDriver_0 started listening on 7777
@twin juniper Look at how ShooterGame handles it
@kindred widget The player UniqueID is unique, that comes from the OSS
So if a player logs in through Steam, the ID will be different than if they log in via some other service
whats the equivalent of #UE_SERVER for the client? #UE_CLIENT?
Also because of stupid naming conventions, don't confuse GetUniqueId() with GetUniqueID()
The one that returns an FUniqueNetIdRepl is the one you want
or can i use #!UE_SERVER
!UE_SERVER ?
There's no UE_CLIENT in Build.h
But then there's no client build target either
Just the "normal" one
I thought OnDestroySessionComplete would be called when the host closes the session.
Apparently it's called when the session is "completed"? According to ShootergAme
* Delegate fired when a destroying an online session has completed
*
* @param SessionName the name of the session this callback is for
* @param bWasSuccessful true if the async action completed without error, false if there was an error
*/```
@limber gyro It's not strictly speaking the same thing tbh
In here they don't even handle the client returning to the menu ```void AShooterGameSession::OnDestroySessionComplete(FName InSessionName, bool bWasSuccessful)
{
UE_LOG(LogOnlineGame, Verbose, TEXT("OnDestroySessionComplete %s bSuccess: %d"), *InSessionName.ToString(), bWasSuccessful);
IOnlineSubsystem* OnlineSub = Online::GetSubsystem(GetWorld());
if (OnlineSub)
{
IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface();
Sessions->ClearOnDestroySessionCompleteDelegate_Handle(OnDestroySessionCompleteDelegateHandle);
HostSettings = NULL;
}
}
@twin juniper It's not, sessions are managed locally - the Server doesn't interfere with the clients' local session
BTW, APlayerController literally has a client function called ClientReturnToMainMenuWithTextReason
But the question would be.
When would that be called.
Is what I'mc onfused about.
Likely a few seconds before the Server ends and destroys the session
Also, AGameSession::ReturnToMainMenuHost() calls that
So when my host closes the game, the client's game crashes. And I'm wondering do I handle that inside OnDestroySessioNComplete?
Ah.
It does, so maybe
I'm doing something wrong then.
Could it have to do with not clearing delegate handles?
Because it's weird that they assign delegate handles.
It could be literally anything tbh
I don't assign any
In my code.
Yah I'll see if the log file
produced anything
On the crash
but yeah to handle it "gracefully", the Server would call some function that tells the clients to go back to the menu
The clients would clean up their own session locally after that
And the Server would then end/destroy it's own session
Ah okay.
Probably a few seconds after notifying the clients to go back to menu so that most of the time it's handled "gracefully" by the players
Alright, thank you. I'm going to investigate this crash.
I'm not sure what the default behaviour is on a host disconnect but it should probably just return you to the default entry map in project settings IIRC
Well I'm not sure if Steam's subsystem plays any roll in it.
But that's what I'm using.
Shouldn't do I don't think
Okay.
ALso I'm getting a huge list of these warnings
Warning: STEAM : Failed to parse settings from key SlotPublicmax value 16
Don't know what these warnigns mean
But they repeat quit a lot
Not sure
looks like you're setting some custom meta data on the session settings or something
hmm
Can anyone help me ?
The problem is that I can create a server (Normal session) but when a friend tries to find a server he cannot find it whereas when I try on the EU project it works. On Android (I have activated the Online Subsystem GooglePlay plugin)
@agile wraith there is fundamental problem here..
Both the server and client should use same OSS...
And Android OSS can't run on your server...
what should i use as a server?
Something like steam or EOS
I have zero experience with steam..
#epic-online-services -> for EOS
I can't help with steam... Haven't even opened the steam website
@agile wraith are you using dedicated server or listen server?
Listen server
Then it should work, my bad I didn't ask earlier
What it sould work ? Steam or EOS ?
I m not sure though, but Google Play OSS doesn't allow your to create session and join session.
Steam or EOS requires good skill and understanding..
If you believe you have good skill you can use either
This service was pathetic.. so I m not surprised it shut down
Yes but for debutant is bad
Don't know about iOS, but you can explore that .
I'm adding a health bar widget to my character like this
void ABaseCharacter::BeginPlay()
{
Super::BeginPlay();
ServerSetupHealthBarWidget();
}
void ABaseCharacter::ServerSetupHealthBarWidget_Implementation()
{
MulticastSetupHealthBarWidget();
}
void ABaseCharacter::MulticastSetupHealthBarWidget_Implementation()
{
UPlayerInfoWidget* HealthBar = CreateWidget<UPlayerInfoWidget>(GetWorld(), HealthBarClass);
HealthBarComonent->SetWidget(HealthBar);
HealthBarComonent->SetVisibility(true);
HealthBarComonent->RegisterComponent();
}
But on the clients game every pawn has a health bar except for the pawn controlled by the server
picrel, on the server side everyone has a health bar, on the client side everyone except the server pawn
I think the best place to set health widget is when PlayerState is replicated to client.
You can skip explicitly calling a function to set health bar.
@meager fable
Could you elaborate? Not sure when or where is player state created and how to I move the widget creation there
@rich ridge
How would I broad cast a message to all available clients connected?
Multicast in a Class that they all have, like the GameState.
So create a delegate and implement the delegate in the game state?
The Character Healthbar Widget stuff frm @meager fable is wrong in multiple ways.
- BeginPlay already calls on everyone, so you are basically performing a ServerRPC + Multicast for no reason.
- Let's assume you do perform that Multicast, it will only happen for the Players connected at that point.
So the Server will do this and probably only reach their own Character.
@twin juniper Well, if you need a delegate, sure
@meager fable inside Character or PlayerController class you can override the OnRep_PlayerState function
I mean, would the server need access to every player's game state to multicast @thin stratus
And here you can attach health bar
@twin juniper server has autonomous authority to everything including GameState, PlayerState , PlayerController, etc
Server can access everything
Why would you use the PlayerState though
You can just do it on BeginPlay
Just strip all this RPC stuff
So if the game instance, calls a method from the game state, essentially that method would be called on every client right?
@twin juniper There is only one GameState and the Server has to execute the Multicast
No, it requires a Multicast RPC
That "Method" needs to be one at least.
Alright thank you for the advice, I"ll look into it.
UFUNCTION( Client )
void ClientRPCFunction();
So when the server calls this
All clients execute it
Correct
o.o not correct
That's a Client RPC. That only calls on the Owning Client
There is no Owning Client for the GameState
No
π
Hmm
GameState exists ones and everyone has it
Read my compendium please. You seem to have a great lack of basis knowledge about this
Yes I do
Moved the code to BeginPlay and everything works fine, thats weird cause I swear I started playing with RPC's because something was broken when calling from begin play lol. Anyway thanks @thin stratus
Hey @thin stratus I want to thank you for this awesome book you have made, it has really helped me understand the network as there is not a good documentation on unrealβs docs.
UFUNCTION( Client )
void ClientRPCFunction();
@thin stratus I m total not in sync, how it won't executive on clients ...
@inner cove Glad it helps (:
@rich ridge Client makes it a ClientRPC. That executes on a Client if the Actor is owned by one.
The person asked to have an Event call on ALL Clients, which is not achieved by a ClientRPC but by a Multicast.
I can't make it any more clear :<
My bad, I didn't read it properly
I'm not sure if I'm even looking in the right place. I'm trying to use the OnlineIdentityInterface to call GetUniquePlayerId, but even the include for that won't work. I have OnlineSubsystem module added to dependencies but this include fails? #include "Interfaces/OnlineIdentityInterface.h"
Never mind, VS mess up I guess. Deleted typical project files and rebuilt and it's fine.
Hello! Currently, I have game settings (team names, team ai #, and more) stored in the player instance (details are set at the main menu before the level is loaded). This seems to work fine for single player but online it appears to fail for the server host and for the clients. What is the proper way to set up a game and carry those details thru into the level where it will be utilized?
Hello everyone & @thin stratus
I've been trying to solve a problem for at least 2 days
My 2 clients connects the server (server waits in a lobby level) and my dedicated server travel to an actual game level
has anyone had issues with Launchcharacter causing desync between server and client?
The problem is; when I do this I can't get a valid player state at the server
I'm trying to get the player state from the connected controller but it returns null (since this is a seamless travel, I can't use the PostLogin so I'm overriding these methods; HandleSeamlessTravelPlayer, HandleStartingNewPlayer_Implementation,GenericPlayerInitialization)
Do you have any idea why this is happening
I cannot connect to a game on my LAN via the console command "open [ip address]".
If that doesn't work then maybe that is why join session doesn't work either. I didnt change anything between the time it was working in 4.23 and the tine it stopped working in Feb 2020 (been trying to figure out how to fix it since then)
Quick question about dormancy
Do awake actors go dormant when not changing?
I can not connect when my PC is hosting and trying to join my Android, nor when Android is hosting and trying to connec to PC
Seems like only PC can connect to itself.
@peak star yes because you are using a windows OSS
I am using onlinesubsystems null just like i was when the game was working between windows and android
@gray scroll before Feb 2020 i was able to play android build apk vs windows build exe with both using LAN in onlinesubsystems NULL
yea onlinesubsystem null should work on both
It really was working on LAN but suddenly stopped. IDK how to tell if it is my router or my OS
I know steam OSS doesn't work on Android (it won't even build to android if I include that plugin)
I don't need my game to work online, just on LAN. Wish I could go back in time to when it works.
What's the proper way to shutdown a dedicated server? Is the quit function enough to close it?
Would anyone know why adding impulse to a spawned item would prevent it from spawning on client but not on server?
guys, Anyone have an idea how to exclude a plugin for server, and all its dependencies ?
Anyone here use Playfab who can help me out for a sec?
I am trying to setup a login system using the docs
and I keep getting this error:
LogHttp: Warning: 000001292EB46B00: invalid HTTP response code received. URL: https://144https://ea25c.playfabapi.com/52.13.201.178/Client/LoginWithCustomID?sdk=UE4MKPL-1.40.200629, HTTP code: 0, content length: 0, actual payload size: 0 LogHttp: Warning: 000001292EB46B00: request failed, libcurl error: 6 (Couldn't resolve host name) LogHttp: Warning: 000001292EB46B00: libcurl info message cache 0 (Could not resolve host: 144https) LogHttp: Warning: 000001292EB46B00: libcurl info message cache 1 (Closing connection 19) LogTemp: Error: Something went wrong with your first API call. Here's some debug information: Request Timeout or null response
I am using the static IP that playfab says on PlayFab static IP addresses
@eternal canyon your url is messed up
yea i was trying to fix it and i cant figure it out
Hey everyone! Quick question: Im using "ChoosePlayerStart" to assign players to spawn points, but if I spawn 2 clients and have 2 spawn points, one client fails to spawn. If I have 3 it works though! Is this the server occupying a spawn point? Im cycling through the PlayerArray to spawn players
Okay this is weird@gray scroll. I just now built for both device types, windows and android, but this time developer build. And now I can connect over LAN again. What's going on?
Something special about shipping builds makes them not work on LAN I guess?
Too bad Google Play Store won't let me publish if it's not Shipping build π¦
@fierce oriole I think the default ChoosePlayerStart doesn't check to see if someone's standing in the way of the playerstart it chooses, so it might fail to spawn because the spawn point is blocked.
Guys, how to exclude plugins for different platforms ?
@peak star if i have 2 players they only both spawn if there are 3 spawn points, like as if, something invisible is taking one before the clients
@fierce oriole Are you using blueprint node to spawn the player pawn?
@peak star you can publish the debug build on play Store
In the second half of 2021, new apps will be required to publish with the Android App Bundle on Google Play. New apps larger than 150MB will have to use either dynamic feature delivery or dynamic a
And sell it too?
@gray scroll Aww man now it doesn't work again. I don't understand why it works only 1 out of 100 times. Maybe it doesn't matter if it's shipping or not after all, except I at least once in a while got it to work in a dev build.
@tranquil yoke I'd like to know how to exclude plugins for diff platforms too, but I don't know if you can. If you can, that'll save me from having to maintain different projects for the same game.
does Unreliable work with NetMulticast functions? the docs for UFUNCTION say its only valid with Client and Server, but the multicasts are not gameplay-critical so i don't care if they're dropped
@peak star Thats sad
WhitelistedPlatforms?
@vivid seal yes. I am almost always doing them unreliable
How do you guys handle replicating damage events? Replicating health with a RepNotify to update the UI obviously, but what about floating combat text? If I want to use the actual Damage event on clients to see what kind of damage it was, if it was a Crit, etc. Iβd need the whole event, not just health replication.
So to solve that I was going to just multicast damage events to all clients to respond to, but then I have that AND the health replicating as well. Is that how you all are doing this kind of thing?
@vivid seal this becomes a bit simple if using GAS, for example for crit damage you could apply CritGameolayEffe ft and it can it's own UI data.
For every DamageGameplayEffect you can have its own UI data.
If you are using traditional float stuff, then you need design your own robust system or framework like GAS.
@vivid seal yes, you need both of them.
@vivid seal I guess ClientRPC is enough for you, ClientGotKnifeDamage, ClientGotBulletDamage, etc ...
Is low ping an accurate way to determine if the games networking good or not?
Sometimes I get jittering pawns/collision even with a low ping on my projects.
What's the proper way to shutdown a dedicated server? Is the quit function enough to close it?
@soft relic if u have command line opened, then CTRL+C is enough
quit command should be also good
Can I not make server calls from a widget event graph?
Update: you can't.
Only PlayerController, GameState and Possessed Pawn can
You most certainly cannot RPC from GameState
As to widgets they should not replicate
I'm not looking to replicate a widget, I'm just looking to call an RPC from the widget
nvm
That's exactly the same thing
RPCs are only supported on replicated actors
(that are client owned, if from client)
got you
Hey, just to make sure I'm not doing something stupid π
When I build the project for dedicated server my entry map should open level 127.0.0.1 (the local loopback)
when I build the project for a client my entry map should open level the public IP of the server
right?
Can anyone help me
To solve this glitch
I can see it only in client not for server
And I don't wish to see it
Then don't look at it 
@twin juniper you don't provide much info so i can't help with that
@inner cove
But I don't wish to see this
Actually in real development there is no such object placed
But when running in client screen I can see this
It is visible only on client screen and for server it is ok and fine
@twin juniper No, the dedicated server (or the listen-server) must open a level/map with the option listen . Now for the client: 1) If the server and the client are on the same machine then the client can use the 127.0.0.1 IP address to connect, 2) If the server and the client are on different machines but on the same local area network then you will need to get the server's IP of that network (If its windows you open a cmd and type ipconfig and look for the IPv4, if its linux type ip a), 3) If the server and the client must connect over the internet then you will need to port forward the server, find the public ip by going to https://ifconfig.me/ or to a similar website and use that ip to connect! (If i missed something or said something wrong correct me)
Get my IP Address
Hopefully an easy question. I have a function that I call from a keystroke to equip a characters weapon. Works fine in MP. However, if I try to call this from BeginPlay within my Character it doesnt work. Feels like I have an ownership problem??
@ruby rock Beginplay in the character should work fine. But if you're doing it on beginplay in the character, you might as well just do it only on the server with a SwitchHasAuthority where ownership doesn't matter.
Does any one know whats the best way to make the server start with a random map?
does UE4 have any kind of built in suport for that?
Can someone help me with creating multiplayer
Just press the create multiplayer button
@limber gyro As in choosing a random map to play from or more like creating a procedural map?
If it's just a random map. Make a small array of your maps, and just do Randomintinrange from 0 to (ArrayLastIndex or Array.Num() - 1) Use the random int to get that index from your array and open that map.
Can the server get a connected client's FUniqueNetId?
yep
from their PlayerState
Or you can query the online identity interface with a controller ID
@kindred widget but i cant just open that map, since the server.exe is running in a VM
foe example if i run that in the "beginPlay" equivalent of the gameMode, it will create an endless loop
You could either use the GameInstance(Does that exist on dedicated servers?) to store a variable of map found, or the actual map string and check if it's in the desired map. If not, find a new one. Or make a super simple map that it can load, and use that specific map to select a random map and load it.
Is there an event that's fired when an actor becomes net relevant again? Possibly before notifies are fired?
Ye that idea of a "map selector map" occured to me but i wanted to see if there was anything better than that
@chrome bay By that second one, the online identity interface. That is the same as this, right?
TSharedPtr<const FUniqueNetId> UniqueNetID = IOnlineSubsystem::Get()->GetIdentityInterface()->GetUniquePlayerId(1);
Because running this on the server with a client connected doesn't work. Only GetUniquePlayerId(0) works, 1 never does. I can see both the server and client's different IDs if I run that on each screen with index0, but the server can't seem to see both by using index 1.
I would get it from the player state tbh
You could get it from the net connection maybe
In the PlayerState, that's the PlayerID?
It's first gathered from UWorld::NotifyControlMessage
No
UniqueId
Which is an FUniqueNetIdRepl
Oh maybe GetUniquePlayerId in the OSS is only for local/split-screen players
Ah. I missed that variable! Kept looking at the UObjectBase function by the same function name.
Throws you off a little.
@chrome bay One last general question about this. If I use this to identify players and their assests/stats etc. How do I write this to a savegame, and on reload of the server compare this back to the logging in player's UniqueID? Do I need to save the string thing I read about, and use the function to turn it back into a pointer on server load? I can't save the pointer itself, because it'd be invalid once the map changes or the server is shut down and restarted right?
I believe they have some kind of "as string" function or something yeah
Actually I think internally it's just raw bytes
Hi everyone. I have a map with 25 AI agents each of whom calls the AAIController::MoveTo method at three-second intervals. The dedicated server is on and the number of players is two. The problem I have is some of these agents suffers from time to time an abrupt movement correction like a kind of teleportation. Everything works well in stand-alone mode without any agent teleportation. Does someone know why this issue can happen in multiplayer mode?
Hey, out of curiosity, since I'm sure there's a good reason for it, why does GAS use floats for attributes?
For precision
Applying 0.5 damage, int can't do
One more reason I can think is some of the UE4 components are designed to work in range of [0.0, 1.0]
Example progress bars..
I suppose UE probably has some compression for floats over network as well perhaps
it does make things simpler I suppose
unreal usually uses compression over network only when it would make absolutely no sense not to do so
by default
rest is up to you
(see FHitResult for example, it has few varieties of FVector_NetQuantize)
I see
The begin play on the level blueprint will run on server and on clients when they load the level?
My Team is having trouble with this movement in our BP template; This is causing a lot of problems in our game. Why do we need to sync player movement on the server; if it is replicated by default?
"replicated" is a simple word for a very complex process
But basically you need the entire environment for movement to be synchronized
Problem is, the local player position gets reset if you have a bad connection
CAN ANYONE TELL ME IF I WISH TO ROTATE AN ACTOR AND HOW CAN I FIXED ITS ONE END
@bitter oriole Is this movement system required? Or can we default back to the ue4 default movement?
If you're using character, it's the only multiplayer capable movement in UE4
ue4 default movement is replicated out of the box
and in my experience to change speed i had to do it on the client and server at the same time
hm
Yes, that's how you have to do it
or they start fighting each other
Good to know.
@twin juniper what do you mean?
these are 2 different meshes and I wish to change its orign point around which rotation takes place
@inner cove
hope you got it
I want to change pivot
@chrome bay I solved the client crash for when the host disconnects by creating a delegate for Engine->OnNetworkFailure()
Then in the delegate call UGameplayStatics::OpenLevel
@twin juniper thatβs not a multiplayer related question
@twin juniper https://youtu.be/XPGGATzXVqk
How to Change Pivot Point on BSP or Static Mesh
step 1 : Use the key combo of : ALT + Middle Mouse Button.
step 2 : Hold to move the Pivot Point .
step 3 : To make the change permanent
You have must right-click on the shape and choose Pivot -
and choose "Set...
im testing my game with average latency on both client and server (30-60ms) and im getting considerable lag on the client. When i use netstat it says my ping is 265 which seems really high. Im not really sure how latency and ping relate, but I thought average ping is around 30 and not 265. Is it normal to be lagging at 265 ping, but 30-60 latency?
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.
this is crashing my game server
has anyone any idea?
If you have a replicated variable in a player controller because player controller is on the client and the server it should be replicated? or not. Not really sure.
yes @twin juniper
Stupid question. I am using two bone IK by sending up the effector FVector locations unreliably quite frequently to be replicated to other clients. Is there an effect on me using worldspace locations (FTransforms with positions that can reach well into the 10s of thousands for x,y,z) vs. relative locations which are much smaller in range? The reason I ask is because I need my effector locations to stay stationary on character rotations which works perfectly with world space values, but is a living nightmare with relative. If there is an alternative that allows me to do that with relative values that anyone knows of, I am also all ears.
So I guess the question is two part, but mostly I want to know if larger vectors sent up frequently will significantly impact performance or two bone IK in general vs. the smaller relative vectors being sent.
Is it normal that i am seeing only 1 player controller on the world outliner when I play with 2 clients? That's so weird.
@steel vault the calculations with floats will be the same regardless of the actual value of the float (aside from 0, 1, and 2, which may have some optimizations)
@inner cove PlayerControllers are not replicated
If you're viewing it as a server would I believe you should see both though
I believe it depends on how you launch your game either "As Client or AsListenServer"
yeah you are right, if i play as listen server i can see 2 player controller
i thought that the world outliner shows what the server sees no matter the net mode
You definately want to be able to view what the client does as testing, so its useful to have a client view
yeah that makes sense
(For me its usually because I spawned something incorrectly and am getting duplicates, but thats cause I'm a noob who forgets to check Is_Authority noob)
so another question i have is, i am making a BR and i want when the player X kills the player Y then the player Y dies and views the camera of player X and since i want to make it the "unreal engine way" how should i do it? I tried spawning a spectator, possesing that , setting its view target to the killers pawn and destroying the character that died but that messes up the things on boths sides, it likes setting both clients to use a spectator pawn!
This works, but if i plug the DestroyActor it doesn't.
@inner cove Most likely the RPC gets dropped because the actor is set for destruction at the same time. You might want to move the RPC to the pawn's controller instead of the pawn. Then you can toss the pawn away.
Okay, let me give it a try @kindred widget
@kindred widget Nope, that doesn't work at all!
hi guys, how can I create sessions with password?
I would assume by simply specifying via custom setting that it's password protected. And then sending the password on connection to the server and the server can check in PreLogin or Login if the password is correct. Not sure that's the number one solution though
whats up with character begin play and listen server
Hm?
beginplay to is locally controlled is very odd
Because that's too early to check
Characters aren't possessed on BeginPlay
At least not on clients
That's what you have events like OnPossessed for
ive been using a .2 delay
Yeah worst solution haha
im gonna have to rebuild this pile of crap lul
Never use delays to counter stuff like that
Yeah calls server only but allows rpcs
So if you need the client to do stuff in BPs you can do a client rpc there
[2020.10.27-22.19.37:299][ 0]LogStreaming: Error: Found 0 dependent packages...
[2020.10.27-22.19.37:300][ 0]LogLoad: Error: Failed to enter /Game/Maps/RetrieveTheBioWeaponContainer: Failed to load package ' /Game/Maps/RetrieveTheBioWeaponContainer'. Please check the log for errors.
my server crashes on linux from this
but no errors on windows server
anyone know how i can fix this? π¦
@thin stratus since you are here and I havenβt got an answer yet, could you help with this #multiplayer message
Game instance can be thought of as the game running on your device. No other device can see it or its variables, but the game instance and its variables exist as long as the game is running. Almost everything else gets destroyed when you open another level. But game i stance and its variables live until the app closes.
Game mode only exists on the server. Game state exists on all devices and can replicate. (Already replicates playerstate actors but not playercontrollers- those only live on their own devices and the server)
i have different materials of colours how would i give each player a random material/colour?
@wild mantle use Create dynamic material instance node during runtime in a blueprint, and set vector parameter by name on that material. The material must have a parameter node inside it that controls the color
If you change the parameter on the master material or regular material instance then it will change it for all surfaces that use that material but dynamic instances are new ones created at runtime and are individual from the others.
i kind of got it to do that, i just looped through each player controller and generated a random index in a material array and applied it to the material but it didn't replicate even tho it was server side with multi cast
Wheb you create dynamic material then I think it auto assigns the New dynamic instance to the material slot you indicate on the static mesh component
Replicate the function call or replicate the dynamic material instance? I only got it to work by rellicating the function call that creates the dynamic material instance. I Passed color in as params to the multicast function
so every device makes the same random color for that actor
Or you can choose random color on the client side of the.multicadt event handler so it looks different to everyone
the node to the left of this is a foreach looping through player controllers and this is all inside a function that replicates
oh so replicating all this is pointless
the random generation is done outside locally and then the final set material is acc replicated only inside a function
Depending on the effect you want. If you want the chosen color to be consistent across all devices looking at that actor then you need to choose the color on the server and pass that down to the multicast to be set on the client side
That is how I did it for my game. Chose color on server but actually set it on the clients
this is inside an interface blueprint btw is that ok?
I couldnt get the material change itself to replicate
I dont know if interface can do it but probably can if the thing that implements the interface is itself a connection owning actor such as playercontroller, pawn, or gamestate.
I mean for multicast
Well when you create custom event node you can add input parameters to it when it is selected in your blueprint graph editor. Pane on the side
I had trouble passing a whole color so I pass the red green blue and alpha as separate params
so i can just use a switch has authority node
Yeah that should do it
is that possible in umg interface?
Yes I think so. If not then the isServer bool should be there and you can use that
I think the reason authority switch is not there is because umg widgets are not actors
They don't live inside the level as actors but instead are slate brushes that live in the game viewport
But isserver just checks whether the device youre on is the server
Not sure how it knows but I use it in my umg
Materials are also not actors but can be members of components on actors
And role authority, role simulated proxy, and role autonomous proxy are all actor roles I think
@thin stratus if youre still around, I cant get the cowboy multiplayer shooter example to work over LAN on Android. It doesnt seem to be able to see the pc host.
I know it is possible because i had another game project do it and play android vs pc on LAN but this isnt working on multiplayer shooter project on 4.24.3
Wonder what I am doing wrong or if it is the fault of android OS update or something out of my control like that.
Or how to find out
ah that makes sense
yh i think i got an idea on how to do it
btw
the code i sent u earlier
can we move to #blueprint ?
Ok
ty
what's the best way to handle instant rotation for characters? i tried setting actor rotation on client and send RPC to server to set new rotation. however, i get corrections happening a lot. Do i need to extend character movement component. Also i'm using Gameplay Ability System. I have a Top down game and using GAS for attacking with melee. I get the mouse position and use that to instantly rotate my character towards mouse. I do set rotation before i activate gameplay ability
In #2 play as client, I see both of the player cams with one of the player. Any idea what's wrong?
not sure if I understand your question, but I think you need multiple player starts?
and set which player to start in your World Settings / Game Mode
I have that
Is there a way to visually debug networking?
Or what's going on in the scene during multiplayer
c:\Users\ewn11\Documents\Unreal Projects\paragon 4.25\Source\paragon.Target.cs(48,43) : error CS1010: Newline in constant c:\Users\ewn11\Documents\Unreal Projects\paragon 4.25\Source\paragon.Target.cs(49,94) : error CS1010: Newline in constant c:\Users\ewn11\Documents\Unreal Projects\paragon 4.25\Source\paragon.Target.cs(50,43) : error CS1010: Newline in constant c:\Users\ewn11\Documents\Unreal Projects\paragon 4.25\Source\paragon.Target.cs(51,85) : error CS1010: Newline in constant c:\Users\ewn11\Documents\Unreal Projects\paragon 4.25\Source\paragon.Target.cs(52,36) : error CS1010: Newline in constant c:\Users\ewn11\Documents\Unreal Projects\paragon 4.25\Source\paragon.Target.cs(53,16) : error CS1010: Newline in constant anyone know why I woudl get this error?
This is c# and i am trying to integrate GSDK
Try usong triple backtick to encapsulate code maybe that will allow double backslash
\\
Yep.it works :)
For discord chat i mean
Could someone explain why my text is not updating over the network? I Have a variable named Value that is bound to the text of the widget, when the player right clicks the widget in game it updates locally but for some reason it does not update for everyone on the server.
It's supposed to update Value by one evertime someone presses the button.
Because Widgets dont Replicate, they also dont exist on the Server.
They are Client side only.
Thanks for the PDF, I'll give this a read.
Even beyond networking, traditionally Widgets are only ever used to get information to display from Actors or to call events directly in actors that do gameplay logic. The same generally extends to networking from UI. Put the RPC or replicated variables in an actor or ActorComponent, and use the UI to tell that actor to RPC, or get the replicated variables for display.
Is there a limit to the amount of players in a multiplayer game for the oculus quest?
@flint belfry I haven't heard of a player limit for any platform
This is going to sound so dumb but when an actor replicates, do all the stuff stored inside it replicates too? Or it only replicated the variable inside it that are marked to replicate?
Only the variables marked for replication
Is the PlayerState the best place to store things like the player FireRate ?
i think if FireRate is related to weapons code it should be stored in weapon
as a replicated variable of course
but if its a universal value, for example if its being changed by players level, strenght etc. might be stored in playerstate
π
does any one know what happens when some one tries to connect to a server that is loading a map?
My guess would be you cant. As the server will only listen after it loaded the map. If its still streaming it in, it should work fine.
well i need to make sure that everything is loaded before the players attempt to connect
how do i do that? is there like a status in the server that i can change?
i need to fetch some info from the backEnd before people can join
right now everything works fine, i am getting the info before any player can connect because it only takes like 1 or 2 seconds but i was wondering if that would be a problem if my map takes a while to load when i add the actual assets
Just don't advertise the session until the server is done
That being said, seamless travel handles all this just fine
You have to do that in C++ there are some events you can hook into, which are not exposed to blueprint. I dont know the correct namens from the top of my head. But there is something like prelogin. Were you can decline the login of a client.
How to prevent colliders moving on server that are lerped to replicated position on client from launching the client character into air with massive force?
hey guys, quick question, I have a ball that is supposed to go through a ring. The ring needs to detect the ball going through the ring (ring is filled with a collisionmesh) but is not supposed to bounce off the ball (the ball needs to go through the ring and explode after 0.2 seconds)
these are my settings for the collisionmesh inside the ring
and this is how I set up the connection in code.. but the OnCollisionScoringMeshHit function only get called when I set it to this..
but that bounces off the ball π¦
( and the ball that needs to go through is a physicsbody π )
are you sure that works
i dont remember right now, but maybe you neeed physics collision if you want overlap events with a physics object
nono indeed, if I want it to work with block I need to enable collision again haha
oooh so also with overlap?
okay wait ill try it right now π thanks for replying
I think I already tried that tho haha
π¦ no it doesnt work haha
I think OnComponentOverlap doesnt work for this for some reason
how are you testing, have a breakpoint inside the function? whats your function like in C++
is does get called with Block, but never with overlap
i really dont get whyyyyy haha
\π€ are you sure you compiled your codee lol
I am relaunching the editor from code rn haha
so now it should a 100% be compiled lol
aaaaa this is driving me crazy, the thing is.. it works fine in blueprints haha
can I use GetOverlappingActors in tick or is that really bad?
because that works haha
@chrome bay i cant do that, i am using playfab as my backend and i am not sure how it works tbh
but they will match my players and just send the ip:port and then they connect
The only issue I know of is a pretty major bug that occurs when a server re-travels to the same map while a client joins
Which Epic don't have a solution for, apparently
But the answer to that is to have more than two maps in ya game
the way i have my things set right now is, i call a playfab function to get the info as soon as possible, as of right now ive never had a case where the server never had gotten the info before every one joined
BUT if loading itself takes too long it might
how do I disable physics interaction of CMC ? I have cube with bSimulatePhysics=1 and don't what the character be able to push it.
btw I tried bEnablePhysicsInteraction=0 and it did not
whats CMC?
you probably need to set your collision channels so that the cube avoids the player, also this should be asked in either BP or C++ if its not multiplayer related
If you don't know what someone is asking about it's probably safe to not answer
just trying to help i guess
also CMC could stand for character movement component so i dont think i am wrong
You can't disable physics interaction per-object with CMC
why would he need to disable physics interaction of the movement component in the first place? he can just make the character capsule not colide with anything that is not static?
I assume the object still needs to block the character
But yeah, not sure. Just disable character collision on the object if not
Give it a different collision profile
I've just realised what OP said
bEnablePhysicsInteraction means the character won't push physics objects
It doesn't mean the physics object won't bounce off the character capsule
So yeah, you need to disable collision between the character and the object
maybe he could try setting the weight and friction of the cube really high?
doesn't matter with CMC
by changing collision channel my character can pass through the box. (its door actually)
indeed
I feel like if bEnablePhysicsInteraction is false it doesn't push the box but character and the box still collide and small jumps and jitter happens
Yeah it will do
You can't have physics enabled, then have two objects that block each other not push the physics object
The physics engine will try to resolve the collision and push them apart
bEnablePhysicsInteraction in the character is purely to allow the character to push physics objects, since it's not a physics object itself
It won't affect collision
I want to make a door just like apex legends, I currently made a basic with sweep . but apex legends door is way more professional than mine.
and btw its dedicated server and competitive game so players can stuck between the door
apex doors have 2 states i think
first is the regular "non physics" mode
and then u break it, it starts simulating phycis with a very low threshold on "sleep" for the physics
so i think u want your door to "sleep" very easily when it stops
doors shouldn't be physics objects
i am not sure if sleep is the right therm, but basicly unreal has an option that makes the physics simulation stop when the object reaches a certain limit on movement
That's all you need really, just don't make it a physics object
In Apex, It just opens the opposite direction based on where the person who 'opened' it is standing and continues to 'sweep' move the door until it's closed, for situations like a box or something blocking it open.
and then when u hit it again it simulates again and goes to sleep agains
well ye, making it move and then stoping when it hits something can also work to simulate what apex is doing
π€
UPO
in apex legends if u open the door and shoot or push at it it moves
Do u know a good 3d modeling site?
google.com maybe ?
The UE4 marketplace
I found some but they cost thousands
i feel like this channel became a "general"
Hi, How to save and use inventory on multiplayer ? Better with game instance ? Savegame file or other ?
I have a static mesh actor array for now
Because my item is all droppable
Saving it locally would be very bad in my opinion because 1) Players can modify the file and alter the records, unless you implement some sort of encryption (which again is not 100% safe), 2) If then player switches machine, format his pc, etc... he will lose all his inventory. The best approach would be to have a backend with a database and a rest api and the game server would send requests to that api to retrieve/save the inventory.
Okay, so if i do this, in game, i have to send this item to the server files or databases at each time the player pick up or dropβitem ?
You will have a unique ID for every item that the game has and when the player picks an item then the game server would make an API call to the backend to tell it that the player with the ID xxx picked up the item with the ID of yyy.
- is only true if you don't enable Steam Cloud Save for example, on Steam
You probably don't want your game to require always-online servers forever
You should think twice about it
The costs are high and you'll need to pay years after the game stops selling
Maybe a solo mode but just for dev test
@dusky urchin what type of game is it?
MMORPG
Alright, I'll skip this one
how can you spawn an actor (server and client)
this doesnt work π¦
(it's multicasted)
yesyes
I think my m_ActorToSpawn isnt correct
that is supposed to be a TSubclassOf<AActorYouWant> m_RandomName right?
I don't have that much c++ so maybe someone else could help with that
haha thanks for trying π
@royal rampart FVector Location(0.0f, 0.0f, 0.0f); FRotator Rotation(0.0f, 0.0f, 0.0f); FActorSpawnParameters SpawnInfo; GetWorld()->SpawnActor<AProjectile>(Location, Rotation, SpawnInfo); this is what i found
@royal rampart Is the actor replicated? If so then you only need to spawn on the server, and the client will automatically spawn its own copy once the replication goes through
No need for multicast
The same goes for destroying an actor. Destroy on the server only and it will go through to the client π
so i am tryong to make my server start with a random map, my base idea was to make a new map and in the begin play of that map just get a random number and open a map according to that random number, the random works fine but the node "open level" doesnt, what do i need to do here?
if i untick the "run dedicated server" it works does that mean that it is working on the server but not on the client?
Have you tried running it as a standalone? because unreal multiplayer in editor has some limitations.
im gonna try that right now
can server and client have different game modes on the same map ?
clients don't have a game mode, it exists only on server
heyyyy I have another problem haha
when i attach the ball to the SocketLocation, it attaches in a completely different location
@inner cove that's what I read.. but HUD class if defined in in GameMode
but when i print the socketlocation, it is correct (green dot)
so client At least to have load CDO of game mode to get it
though I probabaly overthink it, might be enough to create two blueprints one with hud and one without ;
@royal rampart have u tried previewing the ball in the skeletal mesh editor (or however its called)?
Actually its the Skeleton Editor
so I can attach a mesh in there?
wait a sec
ill try
i dont know how to do that
On the Skeleton Tree right click the socket and you should see the options there if I remember correct
I clicked create mesh socket haha
is that what you mean? xD haha i hope im not fucking up stuff for my artist haha
tadaaa
can I leave it as a mesh socket?
Yes, leave it as a mesh socket. Make sure the mesh you're attaching it doesn't have an offset or something. I've had that before where the mesh when imported from Blender had some offset to it
nono there are no offsets, it worked yesterday but for some reason it doesnt anymore now π¦
is it possible that the server doesnt know the correct location or somethin?
i changed the grabbing logic a little but the attach function is the same as yesterday
Ah yeah it could well be. If your mesh is set to "tick visible" then it won't refresh on a dedicated server, the socket will be where it is in the T-Pose
I had this issue with a melee system, on the dedicated server the characters just T-Pose so hit detection was broken
well the ball always shows up in the same place when I grab is and it is not the t-pose position haha
haha lol
this is the code
and it's the same as yesterday, my artist says he didn't change anything regarding the bones so it's my fault..
Interesting
but the function is literally the same
like wtf
i can even check through source control that I didnt change this function haha
Try setting all attachment rules to "snap to target" and see what that does
have you checked if the "BallSocket" exists? maybe your artists changed the naming? just random thoughts
nono if you scroll up, youll see it is still there
ahh yes
but the thing is.. it is attached to the BallSocket, but the BallSocket-"bone" is like longer haha
because the ball moves along with the hand movement
it must be something really obvious
π¦
When a variable is set to RepNotify, does also the server run the OnRep function or only the clients?
only clients I think
Yup
have you guys heard anything about replicated floating pawn movement on 4.26?
@inner cove Yes only clients run it, but you can get around this easily by just calling the OnRep function manually when you change the variable on the server
{
if (HasAuthority())
{
ReplicatedVariable = newValue;
OnRep_ReplicatedVariable();
}
}```
virtual bones are not the answer for us either
got a big issue here. we need to attach a thruster particle effect to a socket on wither wing but need the ability to rotate this socket in the animation
@soft girder You can't animate a socket, but I believe you can modify its relative location and rotation in code
damn
What you will need to do is create a separate bone in your skeleton and then animate that
we have a backup plan doing something like you just said
The bone doesn't have to be rigged or anything
It's really just there to act as a parent for the socket
is this something that we need to go back to blender for
Yes, just go back to Blender and add a new bone. As mentioned, it doesn't have to be rigged so it should be a fairly simple job
ok
Just parent the new bone to whichever one makes the most sense (one in the wing presumably) and then you can just modify your animation to include key frames for the new bone, which will be fore your thruster effect
ok
I assume you require the particle effect to rotate independently of the wing?
If you run into problems you can try the Animation channel π
kk thank you
GameMode has some important functions thatβs arenβt exposed in blueprint and c++ takes literally 3-4 minutes to compile in my machine for a single line of code changed π΅
vs2019?
yes
Is using interfaces to control vehicles makes sense in replication? or are there better ways?
other way is possessing the vehicle but not sure if its a good idea since gameplay framworks sucks about it when it comes to replication...
vehicles are not the main idea of the concepts, they are just included in very small duration of gameplay
just need a simple controller
but still i want to take advantages of chaos on 4.26 and vehiclemovementcomponent
oh...
i totally missed the part player pawn is controlling the vehicle (driving), the actual controller class doesnt belong to vehicle..
can someone confirm my understanding please: the replication graph does not actually optimize any bandwidth / networking, it only optimizes the server's CPU usage while iterating actors during networking protocols... and only improves scenarios with lots of actors that need networking
is this correct?
Do you guys have any suggestions on how I could implement a "days passed" mechanic in my game?
There are 2 levels: Day and Night, that the players keep traveling to and fro. How would I keep one variable that persists across levels that does NOT reside in the GameInstance? (I want the server to possess this)
you can use the Options parameter when traveling
There's no such parameter in ServerTravel @inner cove
@unkempt tiger it do optimizes the bandwidth, the whole reason why replication graph was invented is to reduce bandwidth, fortnite have 50k actors and all replicating..
Let's consider one player spawned at one end of map, he doesn't need to know what is happening to actors on opposite side of map.. he is only interested in actors arround him in his sight of radius
@near bison ohh then this must exist only on OpenLevel i guess
That's not very convincing π
lol I think I got it. but unreal has it SLYLY mentioned in the corner of their documentation
@near bison btw the server and every client has their own GameInstance and its not replicated so even if the server store it there, only the server could access it.
that'll work the same for dedicated servers as well right
also quick question: individual variables on gameinstance can be replicated?
that'll work the same for dedicated servers as well right
@near bison yes
also quick question: individual variables on gameinstance can be replicated?
@near bison no
Game instance is only aware of its own executable. Does not have any connection between server and clients.
@near bison no
@inner cove ok so on traveling, I should first extract the variable from game instance on the server, (somewhere, preferrably in game mode or game state) and then I'm good
got you. Was just clearing up some small confusions
@near bison yes, before traveling you should set the variable on the GameInstance and after traveling you can get the variable from there.
perfect man. thanks so much
It would honestly make more sense if Options existed on servertravel, but it's fine I guess
This doesn't make semantic sense, because technically this variable is initialized on all clients for no reason
Haven't tried the seamless travel but this should work as well, but i don't know what cons it has
Haven't tried the seamless travel but this should work as well, but i don't know what cons it has
@inner cove I've tried. GameInstance persists across seamless travel and works, no problems.
@near bison no i didn't mean with the GameInstance, i meant if you set this variable somewhere else like the GameMode
the GameInstance is created when the game launched and destroyed once the game shuts down so it persist even when you change levels.
@rich ridge thanks for replying, but isn't that behavior already implemented with the Actor:IsNetRelevant(Player controller) function?
Just imagine you would have to iterate over these 50k actors to set it
hey guys, for some reason servertravel isnt working on my teams game build, but works in PIE, any idea why? thx
Yes, thats a lot of CPU iterations, but the eventual bandwidth result should be the same, no?
And you need to keep track of which actors too who became relevant every frame
Can you handle that in every frame...
Probably not, but again, only from the CPU side
not necessarily network side
the ability to call Actor->IsNetRelevant basically promises that all actors will be networked to a certain client as long as they are relevant to him
which is what the replication graph does too, so as far as what gets networked - it should be about the same, the question is at what CPU cost? How are those actors iterated every frame?
Hence my question
Which I'm afraid, remains
which is what the replication graph does too, so as far as what gets networked - it should be about the same, the question is at what CPU cost? How are those actors iterated every frame?
@unkempt tiger no replication graph doesn't work like this.
There is a official stream on replication graph where they explained their use case as per fortnite
In rep graph the map is divided into grids..
And the actors replication is decided on basis of grid relevancy to player..
You can specify the grid size as per your game requirements
The Replication Graph eliminates the need for Actors to evaluate each connected client individually, solving the CPU performance issue without sacrificing the client experience
Yes, what PanTrakX quoted
^
From this I understand that
the issue that replication graph comes to solve is that of CPU performance, not networking performance
No it's both
Like I gave an example from fortnite..
The actor which is 5 miles away from player won't be replicated to him at all
Saving bandwidth for you
https://www.unrealengine.com/en-US/tech-blog/replication-graph-overview-and-proper-replication-methods this doesn't says anything about bandwidth but only for CPU issues
Saving network cost..
@unkempt tiger most of the players they die in 2 minutes, so its waste to network , cpu to replicate entire world to players
Replication graph was invented to address these issues
you still didnt explain how replication graph optimizes bandwidth usage, you keep going back to the CPU example
I already explained
It only replicates actors from grid which are relevant to any player
I understand the example you gave me, and I replied with IsNetRelevant doing the same kind of behavior as far as what gets networked is the issue
afaik the grid can be equivalent to any spatial check the IsNetRelevant code does
If you can achieve your requirements by IsNetRelevant, it's fine
Is there anything wrong with/strange about replicating a camera? I'm trying to use the camera's position and rotation for some calculations, and I feel like instead of making two UPROPERTY's I should just tick the replicates on the camera and then I should be good to go, no?
Replicating the camera would do nothing in itself
You need to write code to synchronize clients and server, too
A camera attached to a character though? I ticked it on and it seems to move now.
If it's attached, sure, it's just replicated as existing and attached
Relative movement won't replicate though
Gotcha. I suppose that's just default for projectiles and characters because they have movement components attached usually which deals with all of that for you.
So easy a baby could write it /sarcasm
I'm old school π
Is there any cost savings to not including components on simulated proxy characters. I.E. if you know it isn't a locally controlled character, can you not attach a camera and other components that are usually only used because you are the owner of that character? I imagine if you had maybe 30 characters on screen each with 3 less collision capsules or components that aren't being used that would help a lot? A little?
And to target more specifically, a character with two MotionControllers, certainly doesn't need them on the simulated proxy, so would it help to remove them or is it fine to just let everything ride.
Yes I would think that you're correct, however I imagine for something like the camera component it's setup in such a way that there is little to no overheard to having it on non-locally controlled characters.
I would imagine other components created by UE4 are similiar
The camera might be replicated to owner only
For my setup at least, I have a collision capsule attached as a component to my camera, when I turn on the debug draw, the simulated proxy has the collision debug draw on, so still exists on the simulated proxy character I would assume. It's not replicating anything, but I was curious if having more components like that in general would effect performance at scale over having simulated proxy characters without any of that.
they take memory but in comparison with other stuff its not much, if u have 30 characters in your game you surely have more than 300 static meshes in your level,
and cpu performance its just a little transform math (calculating local2world, aabb, ..)
Ok, so in general, unless those things are doing some crazy work on tick or something it's probably fine to keep them attached for proxies.
I myself like to not spawn redundant stuff but it doesn't worth it, don't like to get weird bugs in future π
π
for instance in my FPS I have 4 components for FP and 4 components for TP (root scene component, weapon, scope, laser, suppressor, ...)
At the beginning of my game in the BeginPlay event I call an event that runs on server and sets a "RepNotify" boolean variable to "True". But all other players still see the value as "False". I can use an "InputActionEvent" to execute the exact same logic and then other clients can see the value as "True". So why is it that "Event BeginPlay" isn't setting it for all other clients?
Anyone here familiar enough with the built in character movement component? I'm really wondering what its approach is for networking states
From a first glance at the code it seems that the state of the player (position, not sure about orientation) is a replicated property that's being replicated about 100 times a second
But from experience (played a couple of games etc) it seems that orientations of players (especially when spectating their first person camera) are really smooth at 144 FPS, meaning it has to be interpolated somehow
Which is confusing, because I know that the character movement component relies on extrapolation of player state (by assuming non-changing inputs), meaning a state gets set as soon as it arrives etc etc
But how does an extrapolated player state work with an interpolated player orientation?
I know that the valve networking model is quite different, in the sense that the player (simulated proxy, that is) is interpolating states across a buffer of 'future' information
@dull lance I'm more focused towards simulated proxy replication
owning client -> server replication is just a stream of inputs and server -> owning client is just a state update, none of which really require smoothing (of course other than prediction)
but how do simulated proxies do it?
they teleprot the capsule and interp the skeleton
Did they fix the problem where you can't join a game on Wifi from Android?
@dull lance nope. Biggest change is the default to Chaos instead of PhysX but that doesn't really change anything about the programming side of things.
speaking of which... looks like preview 6 was just pushed out
err 5
it apparently got better in preview 2 or 3
my stuff isn't too physics heavy so I haven't noticed any problems even in preview 1
im replicating arrays of uobjects using replicatesubobjects in an actor component. this works fine. however, when it comes time to destroy one of the objects, i need to replicate it one last time to alert clients that object is going to be destroyed and pass some information. i did this by having a separate array of "RemovedObjects" that are objects no longer valid but still awaiting replication one last time.
then, in ReplicateSubobjects, i was calling ReplicateSubobjectList on them (as i am with the other arrays), then clearing the array. however, if i do this, the client never gets that last batch of replicated data.
if i instead do a hacky workaround and add a 1 second delay before clearing the array, everything works perfectly. the objects go into the RemovedObjects list, they are replicated again, then after 1 second they are removed completely and destroyed.
i'm trying to figure out why calling ReplicateSubobjectList and then immediately clearing the array AFTER replicating it causes the replication not to occur
in the same function
i figured as much, i just have no idea how it DOES work lol
so there's no way to do in 1 frame:
- Move an object into an array of objects to be replicated.
- Set a Replicated value inside the object.
- Call ReplicateSubobjectList on the array (which in my head meant getting all of the data that needed to be replicated from objects in the list)
- Clear the list so these objects will not be replicated again.
i just mean they won't be considered for replication again. after this property changes and the client gets it the object is essentially done, it's good to be garbage collected or destroyed or whatever, im not using it anymore
i just use the OnRep of that property for the client to fire off any logic before destroying it
its for a buff object, and its just a struct saying how/when the buff was removed
i wanted to use onrep in case there are issues with relevancy. like if client a sees client b has a buff, but client b is out of relevancy range when the buff is removed, client a wouldn't receive the multicast, so client b would still have the buff (but it would be a null pointer?) when he comes back into relevancy
i think i fucked up the structure though
the buff array itself on the component isnt replicated, just the buff objects, and then they tell the client version of the component to add themselves to the client array
with array replication, is there a good way to tell what was added/removed to the array when the onrep fires, or do u have to compare it to the previous state of that array
so the server manages an array of stuff that clients should be deleting, and the clients OnRep delete, how does the server know the clients have received it and remove it from the array
i guess the things that led me here were this:
- the buffs need to be uobject. struct doesn't have enough functionality for everything i could possibly want to do with a buff, actor i was told will be way too heavy on the network to replicate if i spawn lots of them all the time.
- the actual application and destruction of buffs, as well as all the parameters passed to the buff on the server should also be available on clients
- array replication seems kind of inefficient in that every time an array is replicated, i would have to compare it to the local version of the array, find the differences, and then determine what happened (something was added, something was removed, stacks were gained, duration refreshed, etc.)
- properties within the buffs themselves need to be available on both client and server, such as stacks and duration
so my solution was:
- when a buff is created on server, it replicates its "creation event" which will pass all the data needed to make the buff on the server to clients
- OnRep for creation event on clients, the buff notifies the client buff component that it exists and it needs to be added to the ActiveBuffs array
- client side delegates are fired in the buffs component so that things like UI can react
- when a buff is updated (stacked, refreshed), it replicates a LastApplyEvent, similar to creation event, which does basically the same things
- when a buff is removed, it replicates its "RemoveEvent" which will pass the data that describes how it was removed (dispelled, player died, timed out, etc.)
- buff then notifies the client buff component that it has been removed
- delegates are fired, etc.
and that all works exactly as i wanted except that i don't have a good way for the server to know that the clients have confirmed the buff is removed and no longer need updates about ti
other than jsut setting a random delay and then removing it from concern
is there some kind of "OnReplicationDone" callback i can hook into in an actor component to know when replication has happened?
So now it seems like android can work with pc over LAN using open ip address console command as long as I start the PC exe with -nosteam -port 7777
Maybe it is just one of those lucky days whete it works and the command line args dont make a difference? My ini is set to use Online Subsystem null. Steam oss Plugin is NOT installed
So when character movement is replicated. Actor rotation is replicated. But if character movement is disabled actor rotation is not replicated?
Hello. I have a listen server and two clients. I would like to ask how can you add a client variable to a server array?
whats the esiest way to disable actor dick for dedicated server ?
remove component
PrimaryActorTick.bAllowTickOnDedicatedServer = false;
help #ue4-general
@sharp star If the aim is to ensure the array is synced between server and clients, why not just make the array replicated?
@sharp star If the aim is to ensure the array is synced between server and clients, why not just make the array replicated?
@hybrid zodiac I did but it did not work.
Server still says 1 length
Oh I see the problem. BeginPlay is run on server and all clients, so the clients add one entry themselves, then the server sends them another
Make the array replicated, and in beginplay just add the values to the array but only if has authority is ture
that way, server controls what is in the array and replicates to clients so its all in sync, clients dont do anything themselves]
So, just that one?
But I don't think the clients will be able to add their own variable to the server's array?
So you want the array synced across server and all clients, but clients can request to add entries?
Yeap
Ok, so then just add a reliable server function to add a new value
It will then be replicated back to everyone
What's the class used here ?
The base
- BeginPlay executes separately for server and clients
A server actor will have beginplay before any client can connect
- Each client and the server add a value into their copy of the array
- NetMulticast from the serve then broadcasts the servers value, so the clients add ANOTHER value
So for clients, "ShareValue" is run twice
That's why you need "Has Authority" so that ShareValue is only run on the server
There you go, so what happens now is each client in Beginplay requests a new integer from the server to be added to the array
The array is then replicated back to the clients
Server has authority over the contents of the array
What is the purpose of the integer array? What are you trying to achieve with it?
Each player has a unique code and I want them all to be shared to each other
Testing it first with random integer since I don't know how to make random codes yet.
if they are random, server can just assign them
doesn't need a client to tell it to do it
Yeah, you can scrap my Request New Integer function then, just have a random number added to the array in begin play, but only if Has Authority is true
Put it in the PlayerState
In fact you don't need an array in that case
Uhhm, I tried the images and still 0,0,0,1
Also, Has Authority is true?
How do you set that?
Just have a replicated integer value called "Player Code" or something, set it in BeginPlay but only if HasAuthority is true
This is in your PlayerState blueprint
Oh, I'm going to use player state?
Now every player when they join the game will be given a "Player Code". This player code will be shared with all other players too
I was just using one actor
If you want the code to remain unique to the player across their play session, this is the best way to do it
I see
I will try that
Thank you
I'll try to find a way to call functions from player state
The Player State class is basically all information you want on an individual player that should be shared across all other clients
So in this case, their unique code
But you could also use it to hold things like their current score, if you want a score board for example
Or whether the player is currently dead, their name, etc.
You're welcome π
Question: Does pktlag only introduce lag from the server end? what is the command to do the same from client or introduce latency both ways?
Oh wait, I think I only issued the command on server, never mind
Been a while - Role < Owner is accessing a private bariable
use GetLocalRole()
Ah thanks
How would you guys handle a 'reconnection' button? Imagine a game like Overwatch or league of legends, a player disconnects, their power goes out, but you want them to be able to reconnect. How would you implement this? My current thoughts were to store some sort of environment variable, a file, or some other sort of piece of information on the players local machine that would essentially just store the connection string, and once the match is over, that connection string would be deleted from their PC. What would you guys do?
@quick flint no, because then the player can just delete this file and start a new game
Of course
What would you suggest?
Building a 3rd party api is out of the question imo
Well you kind of will need one here
If you want to force players to rejoin, as opposed to giving the option, then you need to have your own matchmaking, I'm not sure you can store state using e.g. Steam matchmaking
If it's just an option a save file with the session id is perfectly fine
^ Exactly
Is there a way to make the packaged executable behave as if it was run from command line with -nosteam -port 7777 arguments, without the user having to type those in each time?
@peak star one options is to do it like that https://docs.unrealengine.com/Images/Gameplay/Networking/HowTo/DedicatedServers/ShortcutProperties.png
can you have conditional replication in GetLifetimeReplicatedProps if the condition is different per blueprint default and never changed at runtime?
and on the target you would pass your command line arguments @peak star
That's how I'm doing it right now, @inner cove but is there a way to do it that doesn't involve the end user even knowing they need to choose the shortcut instead of the bootstrapper exe alone? End user meaning average customer who bought my game and just wants to hit the windows Start key and type the name of my game and choose the top result to play.
so you have
UPROPERTY(EditDefaultsOnly)
bool bReplicateSomething;
and that differs based on different blueprint assets? But it is not changed at runtime
@empty axle per-blueprint class yes, but not per-instance
@peak star i don't know about that and the docs suggest this way i sent so maybe its in your hand to make some guide/documentation for the game on how they should run a dedicated server (i guess that its a dedicated server because you asked on this channel).
@peak star i think you will have better luck asking that on #packaging
A Quit Game node run on a dedicated server will shutdown this dedicated server instance?
Just tested it and it works ^
How can I handle host migration when the listen server closes/disconnects?
Make the server choose a suitable replacement host, tell all players who it is, they try to join that player when the session disconnects
It's not straightforward though
So when the game session begins, the listen server should instantly choose a suitable client as a replacement in case of a disconnect?
And shares information with that client. Then when a disconnect occurs, that player becomes the new host?
something like that I guess. You will still have to transition to a new session and level I suspect
Okay. Well if there isnt much existing resources done on this I can try implementing my own system for it.
On a multiplayer game where do you spawn the HUD/UI (if there is)? On the begin play of the PlayerController or somewhere else?
(I do it on the begin play of the player controller, just want to see how others do it if maybe there is a better way than how i do it)
Do you know how to fix this ?
Gamemode :
Player controller
the player array type is player controller
- Only the server posses a GameMode object so custom events should not replicate
oh
- Set the SelectionCharacterWidget to replicate on owning client
thanks :)
np π
you cant
http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf i would suggest you to read this, it will help you a lot.
ok thx
@rustic spruce don't replicate the hud, replicate whatever data drives the HUD.
In a racing game, you wouldn't replicate data about the speedometer, you would just replicate the speed and then everyone would drive their own speedometer with it.
does it make sense networking entire HitResults from the server to clients via multicasts whenever a bullet hits a player, to display impact effects?
it seems like a lot of bandwidth
but Im having trouble coming up with something else
FHitResult is fairly efficient
but you can get away with a packed vector and a packed normal
Yeah, phys material as well
replicating names is never efficient and maps don't replicate π
perhaps also the bone name to attach to, which I've already mapped to be a uint8
it goes over as string
yeah, like an agreed upon cache
Best practices question: If I'm sending up some data unreliably on tick (or very quickly) and that data is a bunch of vectors and rotators, is it more efficient to send up one big struct with say 5 transforms with 1 RPC call, or would it be more efficient to have 10 RPC calls with each of these values separated out? The reason being: say if 8 of these values do not change and you write logic to not RPC call if the value has not changed, but 2 of them do change you will end up sending the struct with all 5 transforms, when instead you could have just sent the changed value. The real question is, is it more efficient to have a larger amount of unreliable RPC calls with smaller amounts of data (1 vector or 1 rotator) or is it more efficient to have less unreliable RPC calls with a more data: one bigger struct with all of the data encapsulated regardless of maybe only one of them being different?
How would you use those 5 transforms? And will you need rest 4 transforms if you already have latest one?
ATankNoMore is right - best use build in replication and only use reliable RPC calls when you want to get response for sure
Replicating the variables and setting them on server is not an option. These are input values taken from the locally controlled client. They have to be sent up to tell the server what to do. The question isn't whether or not they should be reliable, the question is, if they are all unreliable and they all need to be sent up, is it better practice to send all of them in a struct with one RPC call or separate smaller chunks with more RPC calls assuming that sometimes the RPC doesn't need to be called.
i need console command, not code
Ok, so in general with a large amount of data (10 floats and 3 transforms) being sent up unreliably, it's better practice to combine them and send all at once instead of having 13-16 RPC calls.
I'm also wondering if a struct is even the right way to go. I know @winged badger is always recommend Fast arrays or things that have better serialization, but I'm not sure that would fit the bill for this situation.
Hey, does anyone know how to show a widget to a specific client?
@fallow shadow send a client RPC from the server owned actor/character telling it to show a widget I would think.
So the command should be executed with a custom node set on server?
Or you could simply set a replicated variable like a bool on that replicated actor and then in the OnRep function for RepUsing you can do the action as well. It's essentially the same thing.
well, it didn't work....(The server node choice)
Can you show your setup?
yea
@steel vault i have heatscan weapons that can fire multiple projectiles and penetrate
just a moment
i batch the payload for each hit and send it with a single RPC
Do you batch them into a struct or a fast array?
Ok thanks for the clarification
its not the better serialization its per item callbacks on clients
that make it awesome
Inside the widget(I use this to call the the other function in the player that spawns the widget that i need to show only on a specific client)
This is how the Clicked Player gets it's value
You should never call any type of RPC from a widget
oh let me transfer everything onto the player then.(The player blueprint)
UI in general is never and should never be replicated.
Do all of that type of logic inside the player or player controller
@steel vault what's the context? What exactly are you trying to do.
Are you referring to my unreliable struct? @dark edge
@steel vault I meant to tag FanMan rather.
I am trying to get a widget to show on only one client!
Also i am running a dedicated server
@fallow shadow but the context is an invite to party tho, right?
I would do a party invite like this.
- Client decides to invite someone, they call an event on server called InvitePlayerToParty which passes over the playerstate they want to invite (clients can't see other controllers)
i am sorry, what do you mean they can't see other controller?
That's the flow i should follow?
On client you can only see your own controller.
So anyways, however you do it, you should end up with the sender and receiver of the invite in the GameMode or another server side actor
You could also do it all in the server side of the player controller, if you have a server side way of selecting the invite recipient.
If you are choosing a player on a client, you should send a server RPC to let the server know who you are trying to invite, then the server decides which player to send it to like Adriel was saying and then calls a client RPC on that server side player.
Anyway, you end up with the sender and receiver PlayerControllers or PlayerStates. You then run on client the logic to pop up the right dialogue boxes for each PlayerController
@steel vault ya exactly, you tag them by PlayerState or the Pawn since you can't see their controller. Server-side you can use that to find the controller
Wherever the party system lives, it should be on server so it can see everything. Once it has the sender and recipient, it calls a run on client on their PlayerControllers to pop up the widget.
okay but i have a question. I want the invite to happen through a widget. And i spawn that widget inside my character on a multicast node. Should i swap that node to a server one instead?
so everything related to it should be on server nodes?
Never multicast the spawning of a widget. Never do anything network related regarding widgets. They don't exist over the network.
Network the behind the scenes stuff that causes them to show/hide
I'm more accustomed to C++ than BP but what I think your issue is in your code is that you are trying to send a Server RPC on an unowned player. You need to send the server RPC on your locally controlled player sending the player ID of who you are trying to invite basically.
okay so hold on let me give you the full story because not giving it is not helpful. I right click into a character and then a widget pops up with a few options. The first option is to invite them to your party. If i have understood correctly all of the above part should not happen in replicated nodes!
@fallow shadow yes, that's all client side
Also, i should create an event on server which will then call the other player to whether accept or decline the offer. Let me go back and read about the widget because that part is a bit blurry
So instead of saying clicked player->SendServerRPC do Player->SendServerRPC(ClickedPlayerID).
When you click invite, that's when your PC or Character calls a run on server event with a reference to the Character or it's owning PlayerState you want to invite
Yea your code is wrong because you are calling an event on an unowned player
alright. Let me try and fix all this!
My widget. Which calls the server event with the player i want to invite
My character logic
Also, how do i "own" a character? Do you mean possess?
@fallow shadow no, the connection/PlayerController automagically owns the player it is possessing.
Where are your parties gonna live?
You mean where will i store the players in party?
Ya
I was thinking of an array
I'd recommend GameState
