#multiplayer
1 messages ยท Page 37 of 1
When a server sends a multicast, it's called right away on the server side right ?
4 player starts are there and 2 of them is dev and 2 of them is asura just same like mentioned in code
its spawning STARTED 4 time as i added in the begin of for loop
and call either dev or asur
4 times
yes
You should provide the complete code, I don't see the definition for firstPawn , secondPawn or the type of playerListNum
You can copypaste the code here, using triple ` quotes around it
And the easiest way to debug your issue is simply to use the debugger - chances are either of the pawn is nullptr
not iam getting different type of errors i didnt changed any code i reopened the project and when i build iam getting this errors
i dont know whats this exatly
ok just a min
Classic C++ error of missing a forward-declaration or include
Just read the error log, it's quite clear
Read the full error text very carefully, it spells out what is missing and where the offending code is in your project
Make sure to forward-declare your pointer types
ok its saying for acharacter but i declare it as class?
wait i will send u code
ignore the error we will fix that later for now i will add header
'#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "GameFramework/GameMode.h"
#include "MainGameMode.generated.h"
/**
*
*/
UCLASS()
class MYPROJECT_API AMainGameMode : public AGameMode
{
GENERATED_BODY()
public:
int playerListNum;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "MyGame")
TSubclassOf<class ACharacter> firstPawn;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "MyGame")
TSubclassOf<class ACharacter> secondPawn;
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const;
protected:
UPROPERTY(Replicated)
TSubclassOf<class ACharacter> currentPawnToAssign;
UClass* GetDefaultPawnClassForController_Implementation(AController* InController);
};
'
Need three ` around the code
what?
And like I said, use the debugger to inspect your variables
'''#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "GameFramework/GameMode.h"
#include "MainGameMode.generated.h"
/**
*
*/
UCLASS()
class MYPROJECT_API AMainGameMode : public AGameMode
{
GENERATED_BODY()
public:
int playerListNum;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "MyGame")
TSubclassOf<class ACharacter> firstPawn;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "MyGame")
TSubclassOf<class ACharacter> secondPawn;
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const;
protected:
UPROPERTY(Replicated)
TSubclassOf<class ACharacter> currentPawnToAssign;
UClass* GetDefaultPawnClassForController_Implementation(AController* InController);
};
'''
Three `
okok
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "GameFramework/GameMode.h"
#include "MainGameMode.generated.h"
/**
*
*/
UCLASS()
class MYPROJECT_API AMainGameMode : public AGameMode
{
GENERATED_BODY()
public:
int playerListNum;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "MyGame")
TSubclassOf<class ACharacter> firstPawn;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "MyGame")
TSubclassOf<class ACharacter> secondPawn;
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const;
protected:
UPROPERTY(Replicated)
TSubclassOf<class ACharacter> currentPawnToAssign;
UClass* GetDefaultPawnClassForController_Implementation(AController* InController);
};
this is for header
#include "MainGameMode.h"
//#include "Engine/Private/GameplayStatics.cpp"
#include "Kismet/KismetMathLibrary.h"
#include "GameFramework/PlayerStart.h"
#include "Net/UnrealNetwork.h"
#include "Kismet/GameplayStatics.h"
void AMainGameMode::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AMainGameMode, currentPawnToAssign);
}
UClass* AMainGameMode::GetDefaultPawnClassForController_Implementation(AController* InController)
{
TArray<AActor*> playerSpawnsList;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APlayerStart::StaticClass(), playerSpawnsList);
float randomNum = UKismetMathLibrary::RandomFloatInRange(1, playerSpawnsList.Num());
if (currentPawnToAssign == nullptr)
{
for (playerListNum = 0; playerListNum < playerSpawnsList.Num(); playerListNum++)
{
GEngine->AddOnScreenDebugMessage(0, 5, FColor::Green, TEXT("Started"));
UE_LOG(LogTemp, Warning, TEXT("STARTED"));
if (firstPawn != nullptr && secondPawn != nullptr && playerSpawnsList[randomNum]->ActorHasTag("Asura"))
{
currentPawnToAssign = firstPawn;
GEngine->AddOnScreenDebugMessage(0, 5, FColor::Green, TEXT("Asura"));
UE_LOG(LogTemp, Warning, TEXT("Asura"));
}
if (firstPawn != nullptr && secondPawn != nullptr && playerSpawnsList[randomNum]->ActorHasTag("Dev"))
{
UE_LOG(LogTemp, Warning, TEXT("Dev"));
currentPawnToAssign = secondPawn;
GEngine->AddOnScreenDebugMessage(0, 5, FColor::Green, TEXT("Dev"));
}
}
}
return currentPawnToAssign;
}```
cpp
Now use the debugger to inspect the variables within the loop and you'll have the error spelled out very quickly
Likely firstPawn or secondPawn nullptr, or the tag check is wrong
By the way the random number is probably wrong too, will never pick 0 and should never be a float
tag is right only and none of them are nullptr
i changed this to int and i started from 0 and iam using this in loop
but still same result
Was attaching a Replicated Actor automatically replicated?
I think so iirc. Can that be turned off somehow?
attachment replication right?
Yeah
I'm a bit confused
I know the AttachParent in SceneComponents is replicated
But the SceneComponent (Root of a Weapon) is not
Only the WeaponActor is
Why is this replicating the attachment
Yeah you can disable it, attach rep is like replicated movement
Cause I need it to attach to 1P and 3P Mesh and noticed it's behaving strange
So there should be an override?
But the whole attachment is driven by the SceneComp or not?
Nah by the actor
Ah found it
{
// Empty
}
void AShooterCharacter::GatherCurrentMovement()
{
#if USE_ATTACHMENT_REPLICATION
Super::GatherCurrentMovement();
#else
if (IsReplicatingMovement())
{
FRepMovement RepMovement = GetReplicatedMovement();
RepMovement.Location = RootComponent->GetComponentLocation(); // FRepMovement::RebaseOntoZeroOrigin(, this);
RepMovement.Rotation = RootComponent->GetComponentRotation();
RepMovement.LinearVelocity = GetVelocity();
RepMovement.AngularVelocity = FVector::ZeroVector;
SetReplicatedMovement( RepMovement );
}
#endif
}```
We disable it in HLL for vehicle seats to avoid race issues between the seat actors and the character
Don't you need to disable it for attaching weapons too?
They don't for us either
It doesn't need to
The original if checks || AttachParent
Our Equipment process has an OnRep_CurrentWeapon
To attach to the Owner
yeah, similar here
(inside a WeaponComponent fwiw). All variables are valid
But the Server replicates the Attachment
Hmm that's not happening for me. The weap components aren't replicated are they?
Or maybe weapon has replicate movement on?
The WeaponComponent is an ActorComp on the Character. Basically the Weapon Manager.
It's replicated with an OnRep_CurrentWeapon
The WEapon is also replicated.
The Code does CurrentWeapon->AttachToComponent(CharacterOwner->GetMesh()....);
That works fine but is apparently replicating
I tested it with limiting it to auth and the Client gets the attachment replicated
Which is not ideal cause it needs to attach to 1P Mesh when LocallyControlled
:D still confused
I'm sure you'd also need to do that in your weapons
@chrome bay Ended up just overriding OnRep_AttachmentReplication for the Weapon and removing the Super call. leaving it empty
Seems to fix it. I could swear I never had to do that in the past x years.
It sounds to me like the weapon has replicated movement on
Looks an awful lot like your random value is simply always 0-1 (or 2-3, or whatever indices your "asura" starts are at in the array)
void AActor::GatherCurrentMovement()
{
if (IsReplicatingMovement() || (RootComponent && RootComponent->GetAttachParent()))
It doesn't need to
As soon as the AttachParent is valid it starts gathering the data
// If we are attached, don't replicate absolute position, use AttachmentReplication instead.
if (RootComponent->GetAttachParent() != nullptr)
{
The function is just super confusing to read
Well thats fucking stupid
So in the middle of the function it selectively does stuff based on the AttachParent
Which I guess makes sense, but still..
Ah well, always great to learn something basic 6+ years in I guess
My favourite dumb API decision is actors not replicating when hidden..
Or when hidden and collision disabled, that was it
I mean.. why
There are a lot of those assumptions made by Epic's coders
Widgets not ticking when invisible.
Widgets not ticking if there is no Tick Node in the BP version.
Things like these
I get the widget thing, as they need to be painted first
I remember having that convo with Nick
The C++ Version not ticking cause the BP version not having an empty Tick Node in it is however bullshit
At least something like that was the case
Can't recall
ah haven't seen that one
There are also still functions that silently fail if called before BeginPlay
Which can happen with OnReps
This attachment thing is eternally stupid though. No idea how I've missed that for so long
Yeah me neither. I must have only attached non replicated actors
Fortunately doesn't affect me that much but, so stupid.
I mean
Tbh, it only shows up if you want to attach to different components on client and server
You wouldn't notice otherwise
Hi!
Do you have an idea why I can't find a session that I created and started? I'm using the Cedric tutorial's code.
Thanks!
a server RPC in cpp that calls a non server method should still exist on the server in execution?
i have a replicated variabled set to true in the non server method but it is called from the server, but it looks like its not updating in the client...
for example if this doesnt make sense..
void ServerMethod_Implementation()
{
NonServerMethod();
}
void NonServerMethod()
{
bReplicatedVar = true;
}
the replicatedvar is false on the client
Do we know the exact answer to what it means when it says SIMULATING like this? when debugging in a blueprint?
This will execute on the server
Make sure the var is correctly replicated
And the actor is client-owned
would it matter if it is being cast?
for (int i = 0; i <= SkillLevel; i++)
{
switch (i)
{
case (0):
Src->bCanSit = true;
Src->BasicSkills.bCanSit = true;
}
}
in the non server method
and the server method
APlayerCharacterGASWithAbilities* Player = Cast<APlayerCharacterGASWithAbilities>(Src);
switch (SkillID)
{
case (ESkills::WA_BASIC):
if (IsValid(Player))
{
Status->GrantBasicAbilities(Player, SkillID, SkillLevel);
}
break;
Anything called from an RPC executes in the RPC's context
Hello all, is there to send a API request that I can send to a dedicated server? Iโm trying to integrate with AWS and I want to remotely kick a player out of the dedicated server
No, need to implement that yourself
i didnt get u
Log your "random" index
Doh! I forgot to put the:
GAMEPLAYATTRIBUTE_REPNOTIFY(UPrimoAttributeSetBase, MaxHealth, OldMaxHealth);
Updated the gist if anyone might potentially find it useful in the future:
https://gist.github.com/imstylen/c62ac651cafe3e9c08dd4cb0a6aec253
https://cloud.stylenmedia.com/s/nTYQcejALfZ6Gm5/download/HealthbarUpdating.mp4
Was that a reply to my question?
Yes
Could you elaborate more? Iโm using a third party service, cognito, to sign in users, so how I can ensure no one signs in twice and using the same player login. Unfortunately cognito is stateless when it comes to user sessions
You asked if there was something in Unreal, there isn't. If you want to talk to a server you have to do that yourself
Thanks, Iโll keep that in mind. I did come across an experimental plugin I can try to probe and examine.
Basically you just need some Websocket service running on the server to take your calls
Hi, I have a question with the grabbing in the multiplayer, how to accomplish that? Since I tried now on trigger press run the RPC for run on server. (like on the image) and it's not working, the client is not able to grab anything, server can. Any suggestions?
Hey guys how can i reproduce this for the server ? so every other client gets these effects ? I'm still new to this I hope i wrote in the right channel
I just need it to work in the editor since its for my final exam
Can a UE game built as a dedicated server be run as a listen server only by passing arguments like TestMap?Listen -game?
I would imagine not. The "dedicated server" build of a game is a stripped down version that doesn't have any of the visual/audio stuff and is meant to act as a host for the game without someone playing on that copy of the game.
What're you trying to accomplish?
I was just wondering. I have not learnt multiplayer part yet.
Does it mean that the code we write is identical for both listen sever and dedicated server, the only difference is in building process?
More precisely, when our code is built for dedicated servers, the building tools will remove the unnecessary parts for dedicated servers.
Hello again. Anyone here with experience setting up FPS multiplayer characters? I get the over all concept of having a third person mesh that other players see and a first person mesh that only the player sees. That's simple enough to set up. What I'm struggling to understand is how to sync the locations of the player's arms/hands/weapons between those two meshes. If I were only doing line traces for projectiles it wouldn't matter but I have some weapons that have physical projectiles that have to originate from the barrel of the gun. Do you normally try to sync this up between the two models or is the client projectile origin in one place and the server multicasts the visuals to all other players regardless of where the projectile is supposed to go? I feel like I'm overthinking this and someone with more experience can simplify this.
Effectively yes. When you're building your game and are going to be using Unreal's networking, then yes, you're making something that can act as either a listen server or dedicated server, and when building for a dedicated server you get a separate package that is stripped down - there's more configuration for what gets included/execluded within the project settings.
There is a caveat though - if you're trying to have both listen servers and dedicated servers available for your application, there's a little bit more thought needed for some of the programming logic flows - usually building for just dedicated is a bit more straightforward, but listen servers you have to take into consideration that the "Authority" can be a player too.
Thank you very much. Very informative. ๐
As a beginner with low budget, I think we usually start learning by building listen server. I have no hosting server to test.
That's not really what dedicated vs listen sort of means.
The easiest way to determine all this is by checking the World's NetMode.
Do you want players to be able to host their own dedicated servers for example?
Usually you don't care about the FPP mesh/TPP mesh positioning at all for firing the actual projectile - you do it from center of screen.
The parallax is usually only significant at short distances so it rarely matters.
And you can "test" running a dedicated server by changing the play mode in the editor to "Play As Client" - that spawns a server process that your editor connects to as a client.
As for syncing positions of the two meshes, also not done AFAIK. Some games do try to do this, but it's much easier said than done and imposes restrictions on animations etc.
I am not sure because most players have no knowledge to host server. ๐ And bothering players to host does not seems to be easy.
I wouldn't care except that there are projectiles like a blaster, or a beam or flamethrower, where the origin of the projectile can't really come from the center of the screen. Visually it needs to look like it's leaving the barrel of the weapon.
Yeah that's what I'm finding out in trying to sync the two. It's very labor intensive and buggy at best.
For particles/visuals you just draw it from the mesh sure
hah PR candidate spotted
That's not really what it's about though. It's about what you intend to make as a game and what you want to allow. Don't think about whether it is easy for players or not - people with knowhow will figure it out and do it if it is made available for them to do.
So it boils down to one of these choices:
A) You have a single player game.
B) You have a multiplayer game where a player acts as a listen server host of the game and other players can join them.
C) You have a multiplayer game where a dedicated server process is running somewhere (either run by players, or by some hosting service) and other players join those servers. Players could still have the option of acting as a listen server host if you allow it.
D) You have a multiplayer game where only you host the dedicated servers and you do not release the server executable to the public, meaning no one else can run a server for your game. This is the choice if you intend to have cross-server persistence for your players. (ie. they can join any server at any time and still have all their stats or what have you)
Cross-server persistence can be fine with C too, if you really don't care about cheating.
Yeah but you also run into the problem that malicious players could basically destroy anyone else's account.
You can do a mix of both, for sure. Randoms joining your server could go wrong, but there's no reason to restrict friends-only servers in that way.
And it depends on where your player's stats/whatever are stored.
You could offer the server for people to host on, but connect to a central hub for per-player data.
And how does said data get updated?
Again, if you don't care too much about cheating. ๐
But Call of Duty has done that method, for instance, and that worked quite well.
(as far as I know)
I think a lot of games have done that with online leaderboards and such.
Online leaderboards are gonna get hacked to shit no matter what you do lol
You should try to make it harder, of course. ๐
And that's the same problem with any kind of player stats when you allow external entities to update the data. Someone'll likely figure it out and can ruin stuff ๐ฆ
Had that happen to me in a P2P game some time ago. The player data (level, items, money) was stored online, but since it's a P2P game it relied on the game clients themselves making the calls to update the data. Someone figures out what your ID is, uploads some crappy data to your ID, and effectively erases all your progress.
Person only did it too because I was kicking their ass and they sucked >_>
As I mentioned, CoD had p2p servers in a previous release. I've no idea if that got hacked.
Vast majority isn't going to muck about.
It's those one or two bad actors that could really bugger things up.
Thank you. Any way, if I play a multiplayer game, how do I know whether I am a client connected to a dedicated server or I may be chosen as a listen server?
The way around that is just to back stuff up and let people complain. Then fix it when they do.
You don't "choose" to be a listen server in that way. You determine that before you start playing. You say, "I will host a game"
Instead of "I will join a game"
I see. I thought being a listen server is chosen randomly. ๐
Some games, when you choose to host, also give you the option of starting a dedicated server. This usually closes the game and starts up a new instance of your game.
That new instance is just a dos box (usually) with no ability to "play" the game from it.
Granted - That would be an ok solution. I guess I lean too strongly on that I wouldn't want the thing to happen in the first place.
I think it depends on how easy it is to do and how many of your userbase will do it compared to the ones that won't.
So what is the difference between:
- one player as a listen server
- one player as a dedicate server and a client on the same machine
It seems to me both are vulnerable to cheating.
If you have a million customers and 100 of them are dicks, it's not so bad, that million other people will fund you fixing the hacks.
You can't be a player and a dedicated server at the same time.
You can have a copy of the game and be a player, and have a dedicated server running on the same machine.
If you have 1000 customers and your stats are easy to hack and you have even 1 person doing bad stuff, it'll be a massive headache.
Technically the dedi server is also a copy of the game ๐
(shhh)
OK. It means there are two executable running on the same machine.
One for playing and one for serving as a dedicated server.
The difference is that the 2 things are not the asme process. You can close the game when you have a dedicated server and other people can still play on it, even if you aren't.
That's the dedicated part.
Yep
Also other implications about game logic and replication, but I don't think that's relevant here.
Hi!
And yes, any time that you allow players to be a host, whether they are a listen server or running a dedicated server, they then have the means of potentially cheating as they are in control of those processes.
Overall, this has no impact on cheating if the player can run the dedicated server. If a player can run any kind of server, cheating will be much easier.
If I'm runing standalone, and I set Player's name in PlayerState, and I join a Session. How can I pass the Player's name to the server? I'm testing the Online Subsystem Null because it is the first time I do this.
Thanks!
Depends on the session. If it's a steam session, for instance, the srever can get your name from your session data.
I think.
I'm testing the Online Subsystem Null because it is the first time I do this.
Ok Thank you. Very informative. It is time to continue learning. ๐
I guess I don't understand then. If I have a physical projectiles which actually travels through the game world, not just a line trace based hit system, it's fine to fire it from center screen? This is why I'm very confused about syncing visuals.
That's up to you. I prefer projectiles to fire from the actual gun muzzle but that's more of a sim-style thing like ARMA or PUBG
Well let's see, a recent example of a non-sim doing this would be Darktide. They have a flamethrower class of weapon which is throwing flames from the muzzle. They have las-rifles which fire a cool beam thingy but I can see how they would just use a separate line trace from the barrel that impacts in the same place the center screen line trace hits. Hmmm
If it's 3rd person it's super important to get your camera aim -> character aim direction system working well
It gets very tricky the further the camera is from the character
So the game is going to be FPS. I'm only concerned with syncing what's going on for the player with what the other players see.
It is possible to run a dedicate server on a mobile phone?
OwningController = OwningController == nullptr ? GetOwningPlayer() : OwningController;
if(ChatTextBlockClass && OwningController)
{
BlasterPlayerState = BlasterPlayerState == nullptr ? OwningController->GetPlayerState<ABlasterPlayerState>() : BlasterPlayerState;
if(BlasterPlayerState)
{
int32 LastIndex = ChatTextBlocks.Num();
UChatTextBlock* ChatTextBlock = CreateWidget<UChatTextBlock>(GetOwningPlayer(), ChatTextBlockClass);
if(ChatTextBlock && ChatTextBlock->ChatTextSlot)
{
const FString TextToDisplay = FString::Printf(TEXT("%s: %s"), *PlayerName, *Text.ToString());
ChatTextBlock->ChatTextSlot->SetText(FText::FromString(TextToDisplay));
ChatTextBlocks.Add(ChatTextBlock);
ChatTextBox->AddChild(ChatTextBlock);
}
}
}
ChatInput->SetText(FText::FromString(""));
thats my code for adding the chat box
but when i enter a msg and hit enter
it says an error
Only Local Player Controllers can be assigned to widgets. BP_PC_C_1 is not a Local Player Controller.
If your crosshair is in red, should the bullet hit the wall?
That's the decision you need to make
Maybe technically but that's an aweful idea
Basically if you have to ask, no.
I get that. But that's a different issue than syncing visuals.
I am wondering why UE staffs decided to complicate the process for building and packaging dedicated server by having us to build UE editor from source code first.
It means that the prebuilt UE editor cannot be used to build and pack dedicated servers.
Any idea behind this decision?
If it can be made complicated why it is made simpler. ๐
Hi, where can i found how FFastArraySerializer works ? It seems to replicate only changed indexes, it should be used everytime an array can change ?
I mean not really. The question is "Where does a bullet appear to fire from and on which machines"
The CounterStrike model has the bullet fire from the camera on server but people see it come from the gun. Although it doesn't really use projectiles so that's sort of a moot point
Ok so maybe the server fires it (in my case) from the muzzle or the weapon, using a line trace from the player camera or weapon sight camera to find it's destination (depending on whether the player is hip firing or in ADS).
Then the multicast to other players shows it firing from the muzzle of the third person weapon and traveling toward the correct impact point from the server? To try to relay some visual accuracy.
Something like that?
take a look at my network manager article for a 101
Where can i find it ?
Thanks !
Hi!
If I'm in a standalone client, and I join a session, which GameInstance will I have? mine or the one that already exists on the server? I'm asking this because I want to store my playerstate on my GameInstance before I join the session, and after that restore the playerstate in the server.
Thanks.
Each machine running the game has its own GameInstance regardless of them being a client or server.
So then? How can I pass the PlayerState from the client to the server when the client join the Server's session?
See page 26 on Network Compendium
"The PlayerState is also replicated to everyone and can be used to retrieve and display data on other Clients. An easy way to access all PlayerStates, that are currently in the Game, is the PlayerArray inside of the GameState Class."
You don't persist it, but instead persist its info in an object that persists, that being GameInstance for example. Though GameInstance as said will exist on client, so you have to be careful the client doesn't misuse that to alter values when retrieved from GameInstance to recreate the PlayerState
I know of a persistent data compendium pinned in this channel, might find it useful
Yes, I've read it. My doubt comes from that. I don't know how I'll restore the data stored in the GameInstance after joining the sever if I have stored on the GameInstance of the client.
client RPC that is on PostLogin, retrieve the client GameInstance, server RPC back with the data while validating it
I feel I could have given that as an example there, so I will note it for myself to add it
Will that be what pushes it past the 60 minute mark? ๐ค
When is "while validating it"? I don't understand "while validating it".
I doubt it. I feel that database mf will be the dude ๐
Pssssh - what do you know
If you are using cpp you get a _Validate version of your RPC
That is used to validate data
Ah. Thanks!!!
Yeah but, if you use C++ anyway, then why persisting in the GameInstance like some BP noob? :D
If you are doing stuff in BP then you will have to make your own version
I can smell a LocalPlayer subsystem from a message away
Or, you know, persisting AInfo Actors for example
But they are hard traveling 
Why hard travel when you can alter the engine so you always seamless travel?
I mean, connecting is hardtravel, so I can give you that
But even then, there are ways that at least don't need the initial ServerRPC from PostLogin
The one I can think of would be to talk to your backend and retrieve data
Which I will do anyways when I validate
No I mean, the Client, in C++, should def have a point where they can send data via an RPC
Without needing the RPC from the Server first
We send SaveGame Data in a Coop game that way
+- cutting it into multiple RPCs due to size
But that's a different story
Ah right, that could prolly be ServerNotifyLoadedWorld?
But well... it's not virtual iirc
rip
hey buds besides 7777 which other (default) port shall I open in the host computer to connect to my server through my vpn?
36745
But yeah my dead brain can't think of what that would be, but good point @thin stratus
fr? thank you!
7777 should be enough
It's just a random port number that is above 10k ๐
4664? That opens Laura port
1337
It's a joke but also not a joke at the same time. In general, I stay away from ports below 10k. I think the guideline is even lower than that, but I give myself some buffer room.
That's the number.
Couldn't remember it
Despite 3389. That thing scares me.
hey, i had a quick question about the functionality of listen vs dedicated? so for listen, i know that there is a local player running, but for example, if i have a set of players and each of them is in a pawn on a different streaming level sublevel
the server would need to have each occupied level loaded and most likely visible, but i want each player to ONLY have their own occupied sublevel loaded and visible
That is not looking to be a quick one
is that even possible with listen?
would the listen client HAVE to have them all open and visible to the user? like a mastermind user?
Theoretically not for the Server, unless you allow Client Auth Movement I guess?
This is a problem that Epic is still trying to solve with World Partition ๐
I mean, it really depends on the scope, but yeah
darn, i guess i would have to default to a dedicated setup? the dedicate server could have multiple maps loaded and visible/ticking, then sending data to each client that only has their room open and active
You do have to realize that some network setups are just not suited for the default server architecture of UE
After all this is an Unreal Tournament Engine, so the whole DedicatedServer and ListenServer stuff is really stuck in the past
Ehhh - it's still quite pervasive today in non-UE engines as well though.
Yeah sure, but we are talking about UE
You can use RepGraph, or even just IsNetRelevant to sort Players
But in terms of putting them into some sort of "instances", it's lacking
Quite a while ago I was wondering if one could make a sort of pokemon game, where the fights would be instanced rooms. But even that is annoying to set up in normal servers
Would probably have generated a GUID and assign that to the Fight and everyone involved and used IsNetRelevant to filter it all
Luckily no collision in that example
Question, I'm currently making a blueprint that functions as a checkpoint. This blueprint calls a custom event on the server in order to save the transform in a variable in the playercharacter. In server it works, but not in client. Is there a chance blueprints that aren't controlled by a player can't call online events?
GetNetConnection() invoked from within a listen server is always nullptr?
If it is a positional checkpoint, I'd say just have a collision box that just saves the transform on the server (can even have it only be loaded on server) @visual urchin
If the client must know about the position for w/e reason, make it a replicated variable.
It gets called from actors not net modes
To answer your question, you cannot call server RPCs on actors that are not owned by the client, similarly, you cannot call Client RPCs on actors that are not owned by a client - all you can do with them is multicast or use replicated variables to communicate. I second Duroxxigar's suggestion.
hi, i need some more help, im spawning actors on the server and then attaching them to each other via attach actor to component node. the spawned items show up on both client and server, but when i run the attach node it only attaches properly on the server, on client it just attaches to 0,0,0 location
By any chance, are you using a listen server? if so, does setting "Visibility Based Anim Tick Option" on your character mesh (in the blueprint) to "Always Tick Pose And Refresh Bones" fix your problem?
yes i am using listen server, let me try that out and see
oh just re-read you post this is not on my character bp it is a separate bp actor that spawns the items and attaches them to each other in the map
That's minor details, character/pawn/actor, whatever mesh your are attaching the actors to, try setting that option.
Usually this issue presents when attaching weapons to characters, hence why I assumed it was a character, but the same could happen to vehicles or any other skeletal mesh, since poses/bones don't update on the server
what would be the best cpu/ram for a dedicated UE Service?
free and unlimited
but the reality is that cloud hosting is the best option if you want to scale
I should follow?
this was already set, and most of my items are static meshes
yes I know need to know the cpu/memory i need more or less @graceful flame so I can pick the correct vm instance type
trying not to spend too much, but also don't want to make it too limited @.@
it varies depending on your game
Well, first of all, what's your use case? Player count, etc
Is this just for development?
production testing
trying to see the cost of use for a single month
and such
since i'm blowing 250usd a month for my current server but thats development I don't think i need that... <.<
so trying to get a more focused on the base min. I should look at
and maybe go 1 node size up or just add more ram
any ideas, would be much appreciated
โค๏ธ
There's no clear number to answer this because it all depends on a lot of variables here
Just use the calculators cloud providers have on their websites
and plugin how much your cpu uses when running as a server
that doesn't tell me the base requirements for a UE Dedicated Service. And if it should have gpu, etc etc.
I know how to calculate costs. ๐ I'm trying to find some mins. for hosting of the service. Googling online isn't giving me alot of info just the editor base
Okay, so I'm not sure about the performance implications of running in a VM instance, but regarding bare metal, I'd usually suggest a 3.5-4GHz quad core, 8-16GB of RAM and you'll probably only need like 50-100GB of storage if it's just for hosting a single server
and editor != compiled game server in terms of resource cost thus why i've been asking
well you probably don't want some onsite database engineer playing your game so I doubt a gpu is required. UE runs headless
How many game instances will you have per server?
it might be more cost effective to have a few large servers with more instances or maybe its cheaper to have many tiny servers with 1 instance
depends on your game
or better yet just give out the server build and let the community host it themselves
I will be doing that but for pre-alpha testing and such trying to keep us hosting 2-3 instances
so we can test all of the game and grid features
and build it for linux and not windows they are generally cheaper to run as well
I'd personally suggest the same as lawlster, just get a cheap bare metal box from SoYouStart, for example, 40 euro gets you a box that can run at least 3-4 servers and you can do whatever you like with it 
Those values aren't really a good baseline because it depends too much on the game itself.
Not needing a GPU is true... unless you write a game that needs one.
If you already have something you can test with, just spin up a few VMs of various spec and see how they perform.
hmm good idea @hollow eagle i'll use @weak linden as a baseline thoughg and i'll spin up a few instances that are larger/more resources to see how things go
but it is just a single service
are you using steam or anything like that just pure dedicated server
that's not relevant to server spec
and I don't want to run more then 1 service per server for stability reasons at least until we can see performance, etc to validate the stability for testing
Right, that's normal enough. Using a small VM per server isn't entirely unusual though it's not as cost effective.
if its just dedicated server you can go amazons ec2 arm servers
true
I plan to move it over to kubernetes and docker contained deployment after the fact @hollow eagle
I have a functional prototype for deployment but I dont have a ci/cd inplace and abuncha other stuff that makes it hard for me to manage it lol properly
so starting with stage 1 testing
then moving to kubernetes
lol
I mean, pick a cloud provider and setup a VM with reasonable specs. Test, then rescale the VM to a new size and test with that.
i'm using GCP
yep I agree @hollow eagle and will do that โค๏ธ
automating everything sucks @.@
its like playing 3 dimensional chess @.@ mental exhaustion is real
on server it attaches everything correctly, but on client it only appears that the static mesh actors can attach appropriately, the skeletal meshes (which hold the static meshes) are not attaching to the main skeletal mesh actor, any idea why this might be happening?
Hello, I'm having some issues with displaying the ready status of my players. The event goes like this, On click, run on server (not is ready = is ready). after that I get the game mode and call Update ready status, Which loops through all the player controller and get is ready and calls Update Player list. the player list is then generated again with the updated information. THE PROBLEM is that on one client it changes all the players ready status and on the other player it does nothing. hopefully you understand it.
You shouldn't need to be storing player data in the game mode. Use the player state. Anything that you need to be replicated you can set as a replicated variable. If you need something that should trigger an event, you set the variable to be a "RepNotify" variable so an OnRep function gets generated.
So then what happens:
Client Presses ready Button > RPC to Server to Indicate Ready > Server gets playerstate of the actor readying up > Server sets replicated boolean "Ready" > (Seperate process: OnRep of the "Ready" boolean can then set client UI)
Any other data that you want to have clients know about a specific player, you should use replicated variables on the playerstate (or at least, a replicated variable of your structure). Not an array of a structure stored on the game mode.
At any time you need to get player information on clients, they can get the player array from game state or the PlayerState from their controlled pawn. If you need to have a UI built up around a specific player, then you use their playerstate as a reference to their specific UI element.
your my saviour, Ill try the rep notify
From the Indicate ready up to when I change the variable in the player state, nothing else runs
If this is in your UI, try getting owning player > get player state > cast > call your RPC
h
the event does get called now
This is what I have now but it doesn't run
Game Mode doesn't exist on clients, so that would only ever trigger on the server.
You shouldn't need to make an RPC to the server on the UpdateReadyStatus interface if you're in the game mode (as game mode only exists on server). Still also questionable why you need to do this at all - you shouldn't need to send the data to each player controller - they can get the replicated "Ready" boolean from the playerstate already (in theplayerstate), and any clients needing to update UI can do so also with the OnRep. Mind if I DM you a set up I've built so you can see how I've done it? It's several images.
yea definitely
if the server creates a component (with replication checked) on a player, does that player automatically replicate the component? I am seeing a very large delay in UI when players attempt to interact with their component's variables
as long as the player is replicated, yes
replication is not instantaneous, so it will replicate when the player actor replicates
you can ForceNetUpdate to get it ontop of the queue
Question, where and how can I run server side stuff for the level. eg: I want to spawn some replicated actors before any player joins?
Real motive is to have like a world manager for a loot system and such
Typically, the gamemode is a good place to spawn gameplay relevant actors, a loot manger is a good example of that
Thank you so much
Did someone say subsystem?!
So, what function/event is appropriate to call to start spawning stuff? I would assume one where the level has fully loaded?
The constructor doesn't seem to be a good option
I would probably just say BeginPlay
oh, can I just call that on a GameModeBase class?
It'll automatically be called by the engine so just hook your functionality onto it either in BP or C++ and it'll work just like that
Really cool and straightforward, appreciate it
Happy to help ๐
hello! Im building a multiplayer game in UE5 with world partition and I want a player to go from a big open world with a directional light to a cave with no directional light. Im using data layers with all actors in either world in their own data layer. When a player goes through a teleporter Im activating the target data layer. Do you know if I can load and unload data layers for a specific player controller? Like I want "player A" to teleport to the cave and later player B can teleport there as well independently. Also is there a way to know the state of a loading data layer? I want to display a loading screen while the layer loads. I cant find much online for this specifically. Would love some insight
what's the idea with UObjects that follow outer chain to get UWorld not being able to spawn actors in blueprints? Am i setting up time bomb for myself by circumventing that?
Are there gonna be issues with replicating/saving/something else if you don't spawn actor from other actor/level bp/game state/other things that are officially allowed to do so?
Hi!
If I have two players and one of them is running as a Listen Server, how can I make it run his code as a client?
Thanks!
Well you can't really, it's the server
Not sure exactly what you're asking though - the idea of a listen server is for a players machine to act as both server and player at the same time
Thanks.
Is there something similar to void OnRep_PlayerName() for PlayerState in Blueprints?
Thanks
Override begin play on your custom player state
It triggers on the client as well after replication.
how PS->UniqueId is generated in OnlineSubsystemNull ?
Im looking for a way to save state of characters
I know in OSSSteam its the same every time player join with the same steam account, but what about OSSN ?
It's random
OSSN doesn't have any service or login info to assign unique IDs' to players
Hi, im having an issue giving the client player input on an actor, im trying to do a security camera system where the player can run up to the control panel actor, press the interact key, then it should disable their input so they cant move while using it and then enable input on the control panel actor itself which is where the input events are to cycle next/prev through the cameras.. ive tried having the EnableInput in RPC calls but i cant get it working so i must not being doing it right or in the right place, any ideas how i can get this working?
Control Panel Actor
Interaction
do I need to RPC DisableMovement or any changes to the movement mode?
your ControlPanel actor is not owned by the client
so Client RPC wont' work
you can call SetOwner on it from both client as it starts interacting and on server when ServerRPC arrives, to the Player's Pawn or Controller
that is assuming your Server RPC for interact is routed properly, ofc
Thats my input atm
So where does SetOwner get called? on the input action or on the control panel actor?
you should always screen blueprints so one can see what blueprint it is, scope matters
but yes
it is generally better to send a pointer to the interaction target through the RPCs to avoid any potential ambiguity
like having 2 interactables in the overlap range, client can decide on one, server on the other one
Hi!
Using GameInstance to save data and retrieve it after player travels (with OpenLevel) doesn't work for one player when that player is a Listen Server. Any advice?
Thanks
sup guys... which would be better for sharing state among many clients?
- let the replication system manage deltas for
UPROPERTY(Replicated) TMap<int32, SomeComplexStruct> MapChangingOftenshared on clients - manage deltas yourself with multicast RPCs?
oh wait, is TMap even replicated properly
U canโt replicate a TMap
yeh just learned. guess that answers my questions!
Do actors with bReplicates=true always get spawned in servers? In other words, we don't need to check whether the running code is in a server, right?
I have question, how it's possible to get recent player that have played the game/match?
What do you mean by that?
For instance, you've played a multiplayer match with 10 other players that you don't have in the friends list, and I'd like to display "Recent Players" in the main menu so you can add them as friends later if you'd like. So is it possible to fetch list later?
You can track that with a backend service. Or just locally.
So every match, just locally log who you're playing against and then when they go to that menu, just read from the file or the backend service.
yup
Aha, great. Thanks for that. I think for now I'll do it locally.
And for adding friends is that has to be done on the backend or it's possible through the subsystem?
No. You must spawn actors on the server in order for them to replicate to clients.
guys where I can find what does this variables mean? I need set up some things for my multiplayer game but I cant find these things in documentation or anywhere else
[/Script/OnlineSubsystemEOS.NetDriverEOS]
bIsUsingP2PSockets=true
P2PConnectionTimeout=6000
ConnectionTimeout=6000.0
InitialConnectTimeout=6000.0
MaxClientRate=100000
MaxInternetClientRate=100000
[/Script/OnlineSubsystemUtils.IpNetDriver]
ConnectionTimeout=10.0
is there any option for URL to change the PlayerName of PlayerState when connecting to server ?
or maybe changing UniqueNetID ?
The below image was taken from docs. Has to do with Epic Online Services P2P connections.
Connection timeouts are definitions of when responses aren't received in milliseconds. So basically everything is set at 6 seconds with no response == the engine will assume connection was lost.
MaxClientRate / MaxInternetClient rate is the maximum number of bytes per second the server/client will attempt to utilize per connection, either for a client on a LAN connection or a client over the internet.
Hi, if i have a RPC with a struct as parameter, how could i use another struct inheriting from this one ? I could use actors replications but i wonder how to do it with RPCs
thank you
link?
we are joined on dedicated server
to session there
tried to inscrease this to be not kicked from session but after 10sec my character dissapeared for other players anyway
How to determine whether the current running code is in a server?
You can do an IsServer branch.
// from AOnlineBeaconHostObject::OnClientConnected
Cast<ANVLobbyBeacon>(NewClientActor)->Test(Lobby); // Lobby is valid
//
UFUNCTION(Client, Reliable)
void Test(ANVLobby* Lobby);
// Lobby has bReplicates to true
Is this supposed to work with this setup ? Lobby is null on the client RPC
Hey guys. I have a strange issue with my game. It's listen server and the host loads in correctly, has the right pawn/controller etc. But subsequent players who join seem to be switching to the default engine pawn for some reason. Anyone know why this would happen? BTW: In my game mode, I am using Event Handle Starting New Player to spawn their character and possess it.
Did you remove auto possess ?
Yes. Auto-possess is disabled on the player character.
Maybe FinishRestartPlayer possess it before you set the pawn
Breakpoint on OnPossess and check who possess your pawn
I can check who's possessing the pawn. I'm not sure what you mean by FinishRestartPlayer possessing it though. If that's the case, how would I fix that?
I have a vehicle actor that is spawning a weapon actor on AActor::PreInitializeComponents. How should I handle the spawning of this weapon actor from a replication perspective? Should I do a check if the environment is the server?
The gamemode possess the default pawn, you could fix that by overriding the default behaviour
Right. That's what I'm trying to do by spawning a character and then possessing it using EventHandleStartingNewPlayer. The default pawn for the game mode would be just fine. The problem is that it seems to be defaulting to like a spectator pawn when players join the session.
Well check the possess events to have more informations
You must be using a source build of Unreal Engine, which you can download from the Epic Games Github.
If your project is using a binary build from the Epic Games Launcher, you will need to migrate it to a Github source build.
Why can't we use the prebuilt binary to package game for dedicated servers?
If I get spammed with these, how bad is that? Is there a simple place I should be checking for issues?
[2022.11.29-21.16.17:403][858]LogNetPlayerMovement: Warning: ServerMove: TimeStamp expired: 185.007645, CurrentTimeStamp: 186.049927, Character: Char
[2022.11.29-21.16.17:403][858]LogNetPlayerMovement: Warning: ServerMove: TimeStamp expired: 185.007645, CurrentTimeStamp: 186.049927, Character: Char
[2022.11.29-21.16.17:403][858]LogNetPlayerMovement: Warning: ServerMove: TimeStamp expired: 185.007645, CurrentTimeStamp: 186.049927, Character: Char```
Hello, I'm trying to make the multiplayer work in my game, but when I join a session I get this. Can somebody help me resolve it?
Because Epic would need to distribute gigabytes more of binaries for each user, the vast majority of them never going to use it
Dedicated servers are for an advanced audience
Those will use a fork of the engine anyway
OK. But providing separately the prebuilt binary for packaging dedicated servers can solve the issue. Users can select which binary to download. ๐
Or the people who actually need a dedi can just compile it
It takes a lot of time to compile build source. ๐
If it takes more than one hour to rebuild the week's version your team needs better hardware
You don't even need to work with dedi anyway
You just need to test it regularly and ship it
So you can integrate that in your CI process
It used to take me 5-6 hours to build from source. Can't believe I thought that was acceptable and I'm so glad I upgraded. Takes about 40 minutes now
There is no problem using "Run on server" in the game state right (Calling the events whenever it is the server instance) ? But using "Run on server" in the gamemode is useless ?
Can't do it. Game State is not owned by any clients so "Run On Server" events called by clients will not run on the server.
Game Mode is only on the server, so yes, using Run On Server events on Game Mode won't trigger if executed from clients (they can't even reference the game mode itself to try and do so)
I think he misunderstands what "Run on server" means.
He think it limits it to only be run when there is authority.
That is not what it does.
If you want to limit code to only happen on server you want Switch Has Authority
hi everyone,
In my game players press a lot of buttons to interact with replicated objects and change their variables. Sadly for me there seems to be a second or so of delay between pressing the button and seeing the number change and it makes the ui feel very sluggish.
I'm wondering what's the intended way to operate a ui like this in a multiplayer environment. I need a synced ui because accuracy is very important, but I dont want it to feel so sluggish either.
Welcome to Prediction, have fun
Is the delay what you'd expect given the ping you're testing with or much more than that?
if it's much more than you'd expect with the ping settings, then look into the replication update rate of the actors. Maybe it's super low
its more than I expected but I don't have anything to really compare against. I imagine most of the games I play have decent netcode so I probably dont actually know what "real" ping looks like
I'm a little surprised unreal wont do prediction of at least variables automatically
or maybe it does, I dont know lol
how do I even get started with that
Things will update quicker if you don't reply on replication, but force the issue with an RPC.
Regular replication is not always instant.
Depends on what variables you want to update, of course.
when you say "force the issue" what do you mean?
obviously I am using RPCs for stuff already in multiplayer but how would it work for prediction?
You haven't actually said what variables you want to change.
There is no "prediction" at all unless you implement it, except for things like positional changes with hte character movement component.
I mean its just things like clicking a button and an int goes up
How is the engine meant to predict you pressing a button? ๐
Prediction works on extrapolating current deltas to estimate future values.
I'm far too anal about my wordage.
I definitely am familiar with the concept
Just have no clue how implementing it works
I take it you are sending an rpc to the server when you hit the button and then relying on regular replication to notify everyone about the change?
Press Button -> Increase Int to new value on client -> RPC to server that you've pressed the button -> Server increments the int and replicates to everyone.
Now you just need to deal with rollback
If the server says no, it should revert the change.
And you shouldn't make major changes until the server has acknowledged it.
yes, I figured this was technically a lazy approach but didnt know what else to do
E.g. you might start to spawn a projectile for a gun, but you'd never kill somebody until the server acknowledged you actually pressed the trigger.
It depends what your variables do to how you deal with this.
So far all we know is, "it's an int"
What you can do is call ForceNetUpdate (whcih doesn't actually force a net update, just makes it more likely) on the object you change or send an rpc broadcast to update all the clients, which happens instantly.
You should also use regular replication as well so that late joiners know the value.
i mean its no more complicated than "press button to make int go up"
I just dont want my ui to feel sluggish while it waits to the new value
So use the above outlined method!
so is ForceNetUpdate fine for "less important" scenarios
Should be called RequestForceNetUpdate() lol
You should also probably block further changes to your int in between notifying the server and receiving an acknowledgemnt.
I assume I wouldnt want to use it on something that relies heavily on reflexes?
(what is QTE?)
At least three quarters of The Last of Us
Quick Time Event.
That is like the hardest problem in multiplayer, it's never going to be automagic
I would not try doing prediction if you can make it work good enough otherwise
Nothing you have said would involve any prediction whatsoever.
I know, but now I'm curious
Things which update frequently and constantly should probably use prediction.
E.g. movement and camera angles.
it's not lazy at all
It's just not quick
The thing is that I don't know the context of the game
how would such a thing be set up? Is it like two variables, where the client updates theirs and then gets a repnotify of the "real" value?
But if it's UI stuff and 99% of the time the client is going to be "right", just go ahead and change the value in the client straight away
Basically.
You assume positive result and act accordingly, but don't do anything hard to undo until the srever acknowledges.
I just knew it would potentially be slow and very ping dependant so figured it was incomplete somehow
Yes, anyway your UI value should be detached from the actual game code
What I would do:
- On button click, update value client side + RPC the event/new value.
-Server performs the logic and replicates the value - OnRep, the client recieves the new server value and overwrites the client-side that we "predicted"
interesting
unless UI has changed much since I did it, you need to manually update widgets anyway when the underlying value changes (unless you are using bindings)
what's the best way to set up the OnRep for the UI? Should I be using event dispatchers or something? Can I somehow listen for OnRep?
UI should communicate via HUD or at least PlayerController
I do use a lot of bindings, are they bad practice?
And the replicated values should belong to whatever class the do, the OnRep will fire automatically and you can write your logic there
Old bindings were, 5.1 introduced a new way I have not tested.
The regular ones are not ideal bcs they need to check constantly if the value has changed, instead of being event based
going from OnRep back to the UI is where I'm not sure
But tbh don't worry about performance yet, I doubt UI is that heavy
UMG MVVM should not be used by beginners imo. Stick with the tried & true event-based approach
There is a way to set it up in C++, no idea about blueprints
This is only true for BP bindings. C++ bindings in the HUD using event based triggers are best practice AFAIK
In BP - you just make it a an onrep variable
Is it all that different?
Needs to be notify
I see, I only have heard about it, never tested, so dunno the difficulty
what on earth is UMG MVVM
It's bindings without poling.
Yeah BP bindings. I am not sure what the C++ bindings are besides BindWidget and the new MVVM stuff
Well, 1 - it is in beta, 2 - it almost didn't even make this release, 3 - no one has really dug into it.
Having someone, whom is a beginner, should stick with the stuff that is for sure to work.
I assume it ties into ufunction setters or something
For BP onrep, you just need to change your variable to this. Then it'll create a function for you in the left side (OnRep_{VarName}). Double-click on that and the code you put in that function will run whenever the value of the variable changes.
If you're in C++, you have to call the OnRep function manually.
Iirc it was binded with the UPROPERTY macro, wasn't it?
You tied the macro to the name of the ufunction that was triggered
Yeah.
UPROPERTY(ReplicatedUsing=SomeFunctionName)
In order to inform the UI should I make an event dispatcher that any open UI can listen to, or do something else?
have you found that to be a better approach for you? I probably wont change my entire project now, lol, but I might try it out if you like it
if you want to "react" from more than one widget, it could be a good idea
no, it's just that the multiplayer code I have written lately is a very specific case that relies on RPCs
Unreal's system is quite good and using it as it was intended will yield the best results almost always
Kind of what I do honestly.
I create an AHUD class that manages ALL of my widgets.
I really need to get into using a HUD
Then I have my PlayerController just talk to that to bind to stuff or call methods directly
right now I do everything in the PC but compartmentalizing all UI things into a hud might be nice for my sanity
Hey Guys, I'm trying to determine how I'm going to approach building interiors in my multiplayer project. Would it be more performant to instance the interiors and have players load a separate map of sorts. Or should the interiors be modeled right into the building itself so no loading would need to be done?
Edit:
Player counts will be roughly 50. Dedicated servers
I have a question regarding competitive multiplayer gaming.
I assume peer to peer or player hosting is out of the question. One issue is that 1 player will have server authority and can effectively cheat. The other issue is that if the player host crashes then the whole game session crashes and nobody can reconnect.
With a dedicated server you solve both of those problems. However how exactly would it work with creating those dedicated servers? Keep in mind, these dedicated servers should not be launched by any player.
I suppose it's ok for a player to host a lobby that other players can join. When they are ready, what happens then? Can they communicate to a 24/7 server somewhere that will create a dedicated server for them? If yes, is there a guide on how to setup in Unreal Engine?
I sincerely appreciate the help on this topicโจ๏ธ
Sounds like you're looking for on request deployers
Following this you would probably have a master server that handles the deployment and keeps track of everything that's needed, basically the player would connect to this lobby / master server, send a request to deploy an instance somewhere on another server (Start match) then handle all the connections and such (Connecting to match)
Don't take my word for it tho, never done it personally, look how competitive games deploy instances, lots of the times they have public explanations for how the server infrastructure is setup
It generally requires a lot of work tho unless you use some sort of service that does it for you, but usually it'll be expensive from what I've seen
Very well. This is about what I expected. I'm happy to have it confirmed
For an example guess you can look at PlayFab
All the subsystems they have implemented and the services they provide
You could honestly even just rely on an already existing platform, let players create Dedicated Servers but only consider progress, achievements and all that stuff on official servers, think like counter strike
It really just depends for what exactly you want to go for
You are absolutely right. Don't worry, I wasn't necessarily looking for an absolute solution right now. I just wanted some insights and approaches. This is very helpful
Is there a way to toggle data layer visibility for an specific player controller?
Question.. Is GI best place to store a client's player token for transfer across two dedicated servers?
My thought is storing it from GS to GI in the beginning of the transfer logic, doing the transfer, and then retrieving it from GI back into GS on connect. From there, it calls the API and retrieves the data to shoot down to the PS, and reassigning the player vars in the pawn. It sounds right in my head, but I wanted to see if anyone has any better advice.
Hi!
I have added a TextRenderComponent to the blueprint third person character. I set it a text, create and start a new session as a Listen Server. The problem is that when the other players join the session, they don't see that text updated on their client window.
Any idea about what it is happening?
Thanks!
the player name is stateful therefore it should be replicated or sent on-join to the other peeps
How?
you are using the playername from the playerstate?
Thanks. I'm new with this and I can't find anything similar to what I'm doing. Or maybe, I'm not searching it with the right words.
Yes.
how are you setting the text?
This is the problem:
I set the text before the other client join the session.
yes, non stateful code causing issues, that's a typical beginner problem, don't worry ๐
but where, how
you'll learn about when to use multicasts, when to not use them
once you do, we can come back here and continue with the explanation ๐
Oh, great!!! Thank you!
multiplayer is tought, we gotta go step by step Elric, I'm sure that if you are determined to learn you'll be able to tackle every time more and more complex problems
but let's start from the very beginning, otherwise it'll be harder
also don't be afraid to ask if you don't understand something that's written in the article, this is necessary
OK. Thanks a lot.
@pallid mesa I don't understand this paragraph: "Since we want new connections to see the new mesh of our Pawn, we are going to employ a state for that. In this case I decided to use an OnRep boolean, which defines whether a player has the new Mesh set or not". I don't know how you use the OnRep boolean to know if I a (new?) player has the Mesh set or not.
I simply set the bool in the server
when the new player joins... since it's a replicated property, he'll receive it and execute the onrep on his machine
when a player joins a game, they receive all the replicated properties from all the actors that are relevant to him
some of these replicated properties can execute some behaviour when they "change" in the client
that's what onrep does... if the new value is different than the old one
onrep will fire
Thanks. I have my custom PlayerState blueprint class, but I haven't been able to find the OnRep for the PlayerName.
The new player will receive the boolean property with the new value (true) and then, the new player, will he run the OnRep code on the client?
correct imagine u join a game
and the game has a property initialised to 7 in the details panel, which happens to be replicated
if u join to that game and the server happened to have changed that property before... you will receive the new one (for example 5)
and since what you have stored in the client doesn't match what just came to you, you will execute the onrep locally
Booh... this is something that upsets me about unreal, the onrep of playername is in C++
I don't think you can override it in blueprints, you should be able to override it in C++ since its virtual...
because of this same reason, we have to do little tricks in Blueprints to achieve the desired result
And this will change the text over the head of the character, isn't it?
yes the behaviour inside the onrep can do that
like.. imagine that every time the player changes his name, u want to make something else
ie: grow his head
this would be the place to do it
so imagine the more characters the name has, the bigger the head
and, if there isn't no OnRep in Blueprints, what can I do?
right since we are unlucky and there's no onrep on blueprints
we have to explore the options we got with this
let me check
Yes, I'm unlucky all the time.
I'm think it could be easier if I use a variable for the Player's name instead of using the PlayerState.
yes you can do that for instance
but if you are using the playerstate
what you can do is to have a playername variable in the character aswell
and every time there's a possession you send the playerstate playername to the character through the server
and let the blueprint character playername replicate
for example...
OK. Thanks a lot! You've helped me a lot.
I have to go now, when I come back I'm going to try this.
Thanks again.
another option you have on blueprints is "on beginplay of your character" wait for the playerstate to be around, and once it is around set the text
because remember beginplay executes in client and server
when a connection becomes relevant to you, the client side begin play will execute for you
why am I saying to "wait for the playerstate to be around"?
Yes, I don't understand that.
- because the playerstate is another actor and it might not exist by the time the character is created iirc -
because... actors replicate independently
and character might have replicated for you before playerstate
How can I wait for the playerstate? Is there an event triggered when the character receives it?
I know in C++ exists.
not in blueprints... you'd have to imply the controller i believe
in fact I don't quite remember what's exposed and whatnot in blueprints... sometimes I forget things
but this is what Jambax and co say...
Blueprints multiplayer is a demo for the whole thing
what you can do is to do a wait loop
A lot of things to learn.
indeed! I'm learning every day aswell!
So a wait loop
in which you check for the playerstate
1: if (IsValid(playerstate)) DoThings()
2: else goto 1
you can do that with a timer, or with a delay
it sucks... but it does its job lol
how destroys the pawn when GM::Logout happens ?
Damn UE5 had 50GB of PDB and I did not download do cant use debugger for engine codes
Ok thanks
Thank you !
Hi!
Do you know if there is documentation or a book that tells about what happens under the hood? For example, what happens when a player join a session on a server? Does the server sent to the player all the replicated data? Which methods run and where they run?
Thanks!
Ok. I checked and it is spawning and possessing the correct pawn but input isn't working now. Very strange.
Hi!
When a player joins a server's session his PlayerController's Begin Play run first on the server, and after that on the client, isn't it?
yes
gm creates pc, dispatches beginplay, postnetinit happens on the client and begplay beginplay is dispatched - iirc
hahaha
I've read WizardCell's peristing data link. I was wondering if there is an (easy) way to make it that nothing persists between levels? i.e. playerstates + playercontrollers are fully reset to initial spawn status. At the moment they are apparently persisted on the server by default?
(this is for some automated editor specific stuff, where I want/need 'stateless' so that they are fully reset)
...yeah - maybe its literally as simple as that and I'm over thinking it - let me go try it out now. Thanks.
yeah thanks - not sure why I was overcomplicating it. And then I can use a custom GameInstance for the 1-2 very specific things I explicity want to carry forward. Thanks
Which version should I follow when splitting code based on ROLE?
Version A
void AProjectile::BeginPlay()
{
/*....*/
if (GetLocalRole() == ROLE_Authority)
{
SphereComp->OnComponentHit.AddDynamic(this, &ThisClass::OnImpact);
}
}
void AProjectile::OnImpact(/*....*/)
{
if (OtherActor)
{
UGameplayStatics::ApplyPointDamage(/*....*/);
}
/*....*/
}
Version B
void AProjectile::BeginPlay()
{
/*....*/
SphereComp->OnComponentHit.AddDynamic(this, &ThisClass::OnImpact);
}
void AProjectile::OnImpact(/*....*/)
{
if (OtherActor)
{
if (GetLocalRole() == ROLE_Authority)
{
UGameplayStatics::ApplyPointDamage(/*....*/);
}
}
/*....*/
}
they both will provide the same end functionality... but I'd say that if you use the former, be explicit with your naming on the OnImpact function and make clear that it runs only on authority
the later consumes a bit more resources, but its negligible
can be handy if u ever need non authorative reactions
In Version A, we need to trace all executing paths to know that ApplyPointDamage() will never be invoked in clients.
In Version B, the intent can instantly be understood. No need to trace the calling history.
mhm, that's why I mentioned that if you use the former, you might want to provide a better naming conv
Thanks. Is there a website, tutorial, book or youtube video where they explain this? Or, do I have to guess it using the debugger?
what I can recommend you is to check Cedric's eXi Network Compendium for starters
@timid moat https://cedric-neukirchen.net/
I think the ue doc explain actor's life cycle.
Thanks. This?
Cedric's is the clearer one for multiplayer.
Which part? I only want to know all the steps involved when a player joins a session in a server. Connection Process section?
from page 112
What happens when you start up your Unreal Engine game? This video is a guided tour of the Engine's initialization process: along the way, we'll glimpse the high-level structure of the Engine (modules, game instances, local players, and viewports) and we'll see how all the different parts of the Game Framework (game modes, game states, player co...
You can have a look at this
But it's not directly for Multiplayer
But probably good for everyone to have a look at at least once
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...
He does have a Multiplayer video, but I don't think that has the lifecycle in it
There's also a TON of explanation done in this specific header through comments ๐
https://github.com/EpicGames/UnrealEngine/blob/ue5-main/Engine/Source/Runtime/Engine/Classes/Engine/NetDriver.h
Thanks.
Hey guys. I have two questions. One is a follow up from yesterday and the other is a general question in preparation for creating my equipment system:
-
I have a strange issue now where players who join my session will be unable to move, almost like the player character isn't registering any input. Any ideas on why that might be?
-
If I want to use data tables to create databases for my equipable items/weapons and plan to have items that are locked until the player meets certain achievement criteria, since you can't modify a data table at runtime, the entire set of items would be in these data tables. So to unlock them, would I have arrays saved in the player's player state (or somewhere else) that load in from cloud stored variables on my target platform? (steam in my case)
Thanks in advance.
That's something I've though: Epic doesn't do documentation because we can read the source code. Thanks!
Hello there how do I replicate subobjects purely on blueprint? I managed to do it on c++ but whenever I try to replicate them purely on bp they just replicate as null
Hello guys. I have some problem with creating widget in multiplayer project (c++) for 2 players. How can I create some widget for every player (but not for copies of clients)? I tried to do client function (UFUNCTION(Client, ...)) where I am creating widget by Cast<ControllerCreatedByMe>(GetController()) and my UserWidget class and then I am adding it to viewport. I put this function into BeginPlay and it gave me an exception. I fixed this by adding validation in BeginPlay (IsLocallyControlled()). But now it looks like finally 2 widgets were spawned by the 1 PlayerPawn (I checked it by the breakpoint and also in the elsewhere in my code I see that widget variable for another player is NULL). It is doing unreal further work with that widget. How can I fix it?
how much overhead is there sending in an RPC like:
MyServerRPC(AGameCharacter* Character) vs
MyServerRPC(int32 CharacterID) ?
basically, sending a Pointer to an existing Actor vs sending a simple int32, whats faster?
from the CharacterID I can get the corresponding actor which is why I'm wondering if it might be better to just send the CharacterID vs the pointer
You're not replicating the entire contents of an actor when you are referencing it if it is a replicated actor, only a small reference (I think the NetGUID or something like).
makes sense, but is the reference/GUID/UUID an int32 too?
or is it a string
Implements a globally unique identifier for network related use.
ah I see
so basically, there's no point in sending a int32 directly, its already optimized enough to send an int32 reference
cool
Are you doing split screen or normal multiplayer? If normal, have you turned off "use single process" PIE option?
It seems to be a normal multiplayer
I chose โas clientโ
No I did not turn off that option
Turn it off
?
Should be in the drop-down beside the play button
Not sure if they've moved it I'm in ue4 still
Go to advanced settings....
I turned it off and got one black window
I waited and got 2 windows
How to debug when one window opened in another process?
Attach to that process.
How I should do this?
It'll be in the debug menu of your IDE
does anyone know how to let people join sessions on your game without them having to be in your organization?
for now im just skipping the loggin but if I want to do player level and such I need a way to let them join with an account
Man, this is so weird. I still can't figure out why players who join my game session can't move. I spawn their pawn, posses it and set input to game mode only in the OnPostLogin event in the gamemode. It works for the host every time but none of the clients. What gives?
I guess I'll try setting the input mode in the Pawn in the OnPossesed event?
is it better to keep scores and rounds won in game mode or player states?
Anything specific to the player that other players may need to know about should be stored in the player state.
Can someone go to discord with me to explain one moment with widgets in multiplayer on c++?
Hi there! New to Unreal and C++ so forgive me my sins. Here's a question:
How do you guys catch NetworkError and TravelError events at the C++ level?
In GameInstance.h we have:
/** Opportunity for blueprints to handle network errors. */
UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName = "NetworkError"))
void HandleNetworkError(ENetworkFailure::Type FailureType, bool bIsServer);
/** Opportunity for blueprints to handle travel errors. */
UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName = "TravelError"))
void HandleTravelError(ETravelFailure::Type FailureType);
but these are not marked as virtual, so as far as I can tell we can't intercept them with an override defined in our derived GameInstance class. Instead, they go straight to the Blueprint.
You are setting it on the server only, that's your issue then
While Spawning and Possessing is indeed a Server only thing, the InputMode is a local only thing
Both PostLogin and OnPossessed are calling only on the Server
I highly suggest not setting the InputMode in more than one place.
What I usually do is have some logic in my PlayerController that checks several conditions each frame and decides the InputMode based on that.
That's also how Epic usually does it.
That way you only set the InputMode in one place, that has all the Info about UI being on the Screen or not (giving you only add Menus etc through it) and it's more or less automated.
Check what is calling those
There should be some global delegate to bind to
I can't recall the names and I don't have an engine at hand to check
Yesterday I wrote my question here, can someone help me?
Widgets are not replicated. You should read the eXi guide in the pinned comments here about how to handle widgets/UI in multiplayer. Essentially you just get them to display local data only
@thin stratus There's not, unfortunately. They get called directly:
void UEngine::HandleNetworkFailure_NotifyGameInstance(UWorld *World, UNetDriver *NetDriver, ENetworkFailure::Type FailureType)
{
...
World->GetGameInstance()->HandleNetworkError(FailureType, bIsServer);
...
}
Do Clients know if the current server they are connected to is a dedicated or listen server? I know I can easily write that function myself, but just wondering if that logic already exists or not in an existing function?
I use listen server, as I know
Is something changing when I change it on "run as client"?
Spawning a Widget only on the Local Clients is relatively straight forward
It looks like widget creates on two copies of one pawn
BeginPlay of your PlayerController with a "IsLocalPlayerController" check should be enough
In a Pawn, you can't use BeginPlay for this
Because the Pawn is not possessed when it calls BeginPlay
So you can't check if it's locally controlled, since it's .. not
Should I do it in my controller?
Depends on the UI you want to show
If it's a generic HUD that is not specific to your Character, then yes
If you have multiple Characters that all need different HUDs, then Character might be better
Then PlayerController should be fine
Also no need for making it a Client RPC. Just in case you are still doing that
I thought that all actions with that widget I should do with a client RPC
Why
When I did a similar thing in another project with Blueprints, it worked
But now I am working in C++
You only need a ClientRPC if you are on the Server and you need to target a specific client
BeginPlay, in for example the PlayerController, calls on Server and the owning Client (doesn't exist for other clients), so the only thing you have to do is stop the code from spawning the Widget if you are not the local player. That's why a simple IsLocalPlayerController check is enough
But there are one difference
In that project there are were abilities to create session and join to session
Maybe it made my way working
There is FOnlineSessionSettings.bIsDedicated
FOnNetworkFailure& OnNetworkFailure() { return NetworkFailureEvent; }
FOnTravelFailure& OnTravelFailure() { return TravelFailureEvent; }
Part of UEngine
// Keep an eye on any network or server travel failures
GEngine->OnTravelFailure().AddUObject(this, &UGameViewportClient::PeekTravelFailureMessages);
GEngine->OnNetworkFailure().AddUObject(this, &UGameViewportClient::PeekNetworkFailureMessages);
// register the engine with the travel and network failure broadcasts
// games can override these to provide proper behavior in each error case
OnTravelFailure().AddUObject(this, &UEngine::HandleTravelFailure);
OnNetworkFailure().AddUObject(this, &UEngine::HandleNetworkFailure);
HandleNetworkFailure calls HandleNetworkFailure_NotifyGameInstance
So yes, there are delegates. You just need to dig a bit deeper next time :P
Ok rad. Thanks. I'll modify my code then.
You already said that :D
Btw, what conditions do you check for in your player controller?
Depends on the game, but the most basic one is if a Menu is open by checking if the UUserWidget pointer is valid and visible.
If no menu is open, I set it to GameOnly
If a menu is open, I set it to UIOnly
+- ShowMouseCursor
And making sure it's only set once by having a member variable. Some custom Enum with the 3 options is enough
So if (NewInputMode == CurrentInputMode) return; where NewInputMode is the one you figured out by your condition and CurrentInputMode is the member variable.
Ahh. Ok. Very cool. And that's checking every frame? Not too expensive?
If I host session using EOS, will I still need to build dedicated server for joining sessions over internet?
EOS is unrelated to if you have a dedicated or listen server - its supports either (same as Steam etc).
It gets a little bit more complicated in games that have more complex needs
Usually to serve those you want to have a counter implemented of objets that it UI only input
once that counter reaches 0, you go back to game input
What exact mean by this?
@woven basin If I made a simple multiplayer game, and If I try to join session using EOS from another computer, will it works?
There is no such thing as a "simple" multiplayer game. But in general, if Computer A is "hosting" a game (as a listen server), the Computer B can join via EOS (or Steam) in theory, yes.
So this means I don't need to deploy a dedicated server on cloud computer?
no, you can do either
Hmmm. I'll have to think about that one for implementation. Thanks for the tip
That's what I am trying to say that If EOS allows us to make/join sessions, then why we need to deploy a dedicated server build on cloud computer?
you dont "need" to. Its up to you.
You can have players host their own games and play with their friends. Or you can host "perisisent" worlds via dedicated servers. Its up to you depending on your game needs etc.
I can deploy dedicated server on amazon etc, and users directly join via ip. why EOS then?
For the same reason that you can program a game using C++ without Unreal. Sure, you could do that, but your just making it harder.
The Online subsystems do alot of work under the hood
Just wait till you have to tell users to manually open ports etc.
Deploying dedicated server is difficult than listen server.
And it's also cost you for cloud computer
So listen server is best option?
If user host a game using listen server, then this means that user have opened connection port to join other players?
does this also means that user computer will "act" as server?
Hey guys, I'm currently trying to replicate a struct which has a void* variable in it but whenever I parse that struct into a server RPC, the value of the void* is always nullptr while other variables are replicated properly. Does anyone know how to fix it?
Hm ok that explains alot. So is there any alternative for void* in addition to TArray<uint8> ?
well my void* is an address to another struct (could be a c++ struct or a blueprint struct). I use void* cause I made a K2 node that has a wildcard input so I could parse in whatever struct I want
No, not really expensive. And yes, every frame
Ok I'll start planning how to implement this. Thanks a ton.
what do you mean by that? ๐
maybe before sending the void*, I could convert it to a UStruct pointer and then send it? ๐ค
FMyStruct
{
UPROPERTY()
Type MyVar
....
}
USTRUCT()
MyOtherStruct
{
UPROPERTY()
FMyStruct InstanceHere
}```
Upon sending MyOtherStruct through the network it will also serialize the instance of FMyStruct
void* is not a type of anything, it is a pointer to memory
I would suggest brushing up on C++ basics if that doesn't make sense, before learning C++ for Unreal
void* is also begging for problems
The appearance void* in code commits is highly related to subsequent firing of software engineers involved in this practice. #changemymind
yes it does make sense to me. But since I want the variable to be a very generic struct, could I make use of template in this case?
No it doesn't unless you provide more context
Replacing one bad idea with another bad idea with no further information to the base of your reasoning doesn't help
provide an explanation of the problem you are trying tos olve
Rather than other guesswork ideas and asking if they might possibly be correct. That way will make it more likely you get satisfactory help
Given that I already implemented all my RPC and built my Actors with the Replication System in Mind.
What are the requirements to Network Test a game outside of the same LAN. I had some problems in the past.
My Research showed me that it would require me to do NAT Punshing. Is there some alternative Systems, Protocols or Frameworks to make it easier (Like Steam).
Also I want to set it up as a Listen Server where the main Client hosts the match. Just the quickest route to Test multiplayer with my Partner: Select Map > Start Game from CLI > Enter IP Address > Join Session to playtest Mechanics.
port forward or vpn probably
nat punching isnt really required unless you want to publish it and want lobbies and shit
in which case you would usually just use like EOS or steam
In WizardCalls guide, he says that console command servertravel is seamless, while travel command is not.
But then it goes on to say that you need to enable AGameModeBase.bUseSeamlessTravel for seamless travel to work.
So when I call servertravel on a map when the gamemode is false for this, is the engine going to force seamless, or will it respect the gamemode?
i mean, cant you just enable it so you dont have these questions?
yes - it was more about just trying to understand how it is layered.
i cant look for you at the moment but if you have the source code this should be pretty easy to find out by searching for the console command
ServerTravel is not Seamless by default.
It depends on the setting in the current GameMode
In case that answers your question
ok thanks... in that case the wording is vague in the guide. I guess servertravel will try to use seamless if the game mode allows it?
yeah - i'll go digging now - thanks
ye sr about that. So currently I'm trying to convert an array of object from a Json file to an array of structs (this part is done locally) and then send those structs data to the server. Here is the example of the JSON:
[
{
"Content": {
"className": " ",
"corpoTag": " ",
}
},
{
"Content": {
"itemDefinition": " ",
"skin": " "
}
}
]
Since each object is a different type from each other, I need a generic struct to hold the data when I convert json object into UStruct using JsonObjectToUStruct (const TSharedRef< FJsonObject > & JsonObject, const UStruct * StructDefinition, void * OutStruct) . So I create a struct called FCustomizationFragment, which has StructType (the type of the struct) and MessageBytes (the data of the struct).
USTRUCT(BlueprintType)
struct FCustomizationFragment
{
GENERATED_BODY()
UPROPERTY()
FGameplayTag FragmentTag = FGameplayTag();
/*Structure type of the fragment.*/
UPROPERTY()
UScriptStruct* StructType = nullptr;
/*The data of the fragment.*/
void* MessageBytes = nullptr;
}
The conversion part is done but I cant replicate MessageBytes of the struct atm.
bool UWorld::ServerTravel(const FString& FURL, bool bAbsolute, bool bShouldSkipGameNotify)
{
AGameModeBase* GameMode = GetAuthGameMode();
if (GameMode != nullptr && !GameMode->CanServerTravel(FURL, bAbsolute))
{
return false;
}
// Set the next travel type to use
NextTravelType = bAbsolute ? TRAVEL_Absolute : TRAVEL_Relative;
// if we're not already in a level change, start one now
// If the bShouldSkipGameNotify is there, then don't worry about seamless travel recursion
// and accept that we really want to travel
if (NextURL.IsEmpty() && (!IsInSeamlessTravel() || bShouldSkipGameNotify))
{
NextURL = FURL;
if (GameMode != NULL)
{
// Skip notifying clients if requested
if (!bShouldSkipGameNotify)
{
GameMode->ProcessServerTravel(FURL, bAbsolute);
}
}
else
{
NextSwitchCountdown = 0;
}
}
return true;
}
void AGameModeBase::ProcessServerTravel(const FString& URL, bool bAbsolute)
{
#if WITH_SERVER_CODE
StartToLeaveMap();
UE_LOG(LogGameMode, Log, TEXT("ProcessServerTravel: %s"), *URL);
UWorld* World = GetWorld();
check(World);
FWorldContext& WorldContext = GEngine->GetWorldContextFromWorldChecked(World);
// Force an old style load screen if the server has been up for a long time so that TimeSeconds doesn't overflow and break everything
bool bSeamless = (bUseSeamlessTravel && GetWorld()->TimeSeconds < 172800.0f); // 172800 seconds == 48 hours
// Compute the next URL, and pull the map out of it. This handles short->long package name conversion
FURL NextURL = FURL(&WorldContext.LastURL, *URL, bAbsolute ? TRAVEL_Absolute : TRAVEL_Relative);
PRAGMA_DISABLE_DEPRECATION_WARNINGS
FGuid NextMapGuid = UEngine::GetPackageGuid(FName(*NextURL.Map), GetWorld()->IsPlayInEditor());
PRAGMA_ENABLE_DEPRECATION_WARNINGS
// Notify clients we're switching level and give them time to receive.
FString URLMod = NextURL.ToString();
PRAGMA_DISABLE_DEPRECATION_WARNINGS
APlayerController* LocalPlayer = ProcessClientTravel(URLMod, NextMapGuid, bSeamless, bAbsolute);
PRAGMA_ENABLE_DEPRECATION_WARNINGS
World->NextURL = URLMod;
ENetMode NetMode = GetNetMode();
if (bSeamless)
{
World->SeamlessTravel(World->NextURL, bAbsolute);
World->NextURL = TEXT("");
}
// Switch immediately if not networking.
else if (NetMode != NM_DedicatedServer && NetMode != NM_ListenServer)
{
World->NextSwitchCountdown = 0.0f;
}
#endif // WITH_SERVER_CODE
}
(also funny that it forces a non-seamlesstravel if the server is on for too long hehe)
ye wtf is that
that function is virtual right
right
There are multiple places like that. Unreal Dedi Servers should not run longer than x hours
So best to restart them frequently
But that has been a thing for years now
if (GameMode != nullptr && !GameMode->CanServerTravel(FURL, bAbsolute))
{
return false;
}
So if I'm reading this right - if the game mode does not allow Seamless and you try for server travel, it returns false?
So how is it getting through then? I'll go digging more...
Try to not misread the function names
It checks if it can SERVER Travel
There is nothing speaking about SEAMLESS Travel at that point
The only thing that can stop SeamlessTravel in that functio nis if you play in editor
Cause PIE doesn't support Seamless
// NOTE - This is a temp check while we work on a long term fix
// There are a few issues with seamless travel using single process PIE, so we're disabling that for now while working on a fix
if (World->WorldType == EWorldType::PIE && bUseSeamlessTravel && !FParse::Param(FCommandLine::Get(), TEXT("MultiprocessOSS")))
{
UE_LOG(LogGameMode, Warning, TEXT("CanServerTravel: Seamless travel currently NOT supported in single process PIE."));
return false;
}
Spoiler: That has been a problem for years and I doubt there is a fix any time soon. So that comment is probably just wishful thinking
ok - so in that case - the real difference between servertravel and travel is "do I want to bring clients along with me"?
And meanwhile, "do I want seamless" if defined by GameMode (which is irrelevant for travel as no one comes along)
I was just trying it then, even with 'seamless' it kicks the clients back to main menu
which is what started this whole rabbit hole trip
now I get it, makes far more sense
Hopefully Wizard can update the guide slightly with the above - it makes more sense that way IMO
Hard Travel when using Steam would kick the Client back to the Menu, yes
If that is what yo uexperience
In general, even without Steam, you want to almost always SEAMLESS ServerTravel
But you can have travel with seamless, but the only person who continues the data is the server - so they carry forward their data and kick clients.
Not sure you would ever "want" to do it - but you could.
So I believe you can have:
servertravel (seamless): keeps clients, keeps data
servertravel (non-seamless): kicks clients (try to reconnect), loses data
travel (seamless): kicks clients (No reconnect), server keeps seamless data across
travel (non-seamless): kicks clients (No reconnect), server also loses data
I can't comment on travel
Non-Seamless Server Travel also kicks clients
The point is that they try to reconnect
Which with e.g. Steam will cause issues
I would need to know what the travel command actually calls internally
Might call ClientTravel
That would explain why the clients don't reconnect
Might even cause the Server to not be a Server anymore (if ListenServer)
cause of the missing listen param
bool UEngine::HandleTravelCommand( const TCHAR* Cmd, FOutputDevice& Ar, UWorld* InWorld )
{
FWorldContext &WorldContext = GetWorldContextFromWorldChecked(InWorld);
FURL TestURL(&WorldContext.LastURL, Cmd, TRAVEL_Partial);
if (TestURL.IsLocalInternal())
{
// make sure the file exists if we are opening a local file
bool bMapFound = MakeSureMapNameIsValid(TestURL.Map);
if (!bMapFound)
{
Ar.Logf(TEXT("ERROR: The map '%s' does not exist."), *TestURL.Map);
return true;
}
}
SetClientTravel( InWorld, Cmd, TRAVEL_Partial );
return true;
}
Yeah so it's just a ClientTravel
I would even say that this won't keep any data
I don't see how this would be seamless
ClientTravels are always hard travels iirc
But not entirely sure
From the looks of it this will cause the ListenServer to become standalone.
And PlayerController/PlayerState doesn't run through SeamlessTravel code
So Travel is just a ClientTravel, an you shouldn't use that for Server Traveling.
yeah - seems like it drops the listen part to prevent crashing it says
So why have it at all? Just use servertravel or if standalone game use openlevel? Why have travel at all?
maybe legacy..
Hi everyone, I have an issue with server client communication. I have an actor component on my character. I have an event in the component that sends a struct from the server. On that event I call another event on Owning Client still with the struct. The client receive an empty struct (but execute itself). Why would that be ?
@glad escarp & @thin stratus & @verbal tendon
You can entirely do away with SetInputMode stuff using CommonUI if you have a little access to C++. It is a much simpler and cleaner implementation than having to track input modes all of the time when you open and close widgets. Basically the leaf most activated widget determines what input mode you're in, and it does it automatically via a simple virtual override. When the widget is activated and it is the leafmost widget, it sets that input mode. So if you have an activated widget for your game screen set to Game, it'll automatically set that when that widget is shown. If you open an inventory where you need the mouse and you return Menu, the moment you open this inventory, it just automatically sets UI only mode. Highly recommend it.
It looks like ScoreWidget spawns on copies of Controller. I made screenshots arranged in order. I don't understand, why the Controller name is the same
How can I know on my custom PlayerState class when the PlayerName has been changed?
Thanks!
Do you have C++ access?
No.
Hm, I haven't actually played around with CommonUI much yet. One of my employees did.
It looked like it was mainly doing what we had internally already coded for the years before CommonUI. There are also some stupid limitations, like filtering the Enter key and things like that.
But automatic input mode handling sounds useful. I would probably try it, but I also like the control of handling it like I currently do
I think this is impossible to do in Blueprint,
I always thought the ?name= param was handled in the Engine already
I don't know.
Game Mode apparently has a callback named OnChangeName when you use ChangeName.
OK. Thanks. I'll check it.
It has been for ages. It may be overridden by subsystems like Steam, though?
/**
* Retrieves this player's name/tag from the online subsystem
* if this function returns a non-empty string, the returned name will replace the "Name" URL parameter
* passed around in the level loading and connection code, which normally comes from DefaultEngine.ini
*
* @return Name of player if specified (by onlinesubsystem or otherwise), Empty string otherwise
*/
virtual FString GetNickname() const;
Anyone ?
fwiw, PlayerState has OnRep_PlayerName
For the question about updating the UI when it changes
Is that a C++ Struct?
It does. But you need C++ to access it. ๐ฆ I put a delegate there after super.
Created from the engine so I would guess no
The name is just generated. It will have _0 behind it locally for every player. This is not a unique name.
So also I don't understand, why ScoreWidget is NULL on the bottom of screenshot