#multiplayer
1 messages Β· Page 648 of 1
I didn't take offense
it's all part of the troubleshooting process
what could be happening, and happens to me is your ISP could be blocking the ports
or theirs is
I had to ask that i need to open some ports
The best action right now is to take a break. Sometimes, fresh air can relax your mind, to a point you start to see whats wrong with your code
i don't think their code is the issue
if it works locally 100%
on 2 pcs
with 2 steam accounts
the code is fine
Yea that"s wierd
Are you specifying any ports? Are the ports open?
NAT has nothing to do with being able to see the session
that's run entirely through the Steam OSS
Can you do a mobile hot spot?
and test from your phone wifi
to yourself
It was a quickly idea that I had, I know its used to redirect the connection request to the correct device inside a network XD. Also, I was thinking about connectivity issues he could have based on the NAT type, if is open or strict... If the NAT of the network where the hosting machine is located is strict, his friend could have connectivity issues, more lag, etc... I don't know how the Steam OSS deals with it
I havent changed anything, i mean idk API of adbbanced steam sessions, maybe i can search for ports informations in thier site
Thanks a lot guys I will write when I find the solution
If it's a NAT problem make sure to try the SteamSockets plugin, it's not on by default
Although I don't know how SteamSockets works in LAN mode, I've never had to use it as I would just use the normal public networking unless you're seriously bandwidth limited. If you're doing LAN for real you probably need to turn off steam networking entirely and fall back to the manual ip/port joining which bypasses sessions entirely
Like that? But it don't get the same effect at all, it's shown on the player screen not above the player
I don't know the right way to create / destroy an widget on an object
Wait. I made a mistake. Use an actor with a widget, not a widget component. That way the client has to spawn the actor, then attach the actor to the target.
It depends on what you're going for really. Having the client spawn the actor with the widget, then attaching it to the target will allow the widget to be shown in either screen space or world space on that object. Since the client is the one who spawned the actor, that actor and its widget will be visible to the client.
With that method, the widget does not need to be added to the viewport since it's part of the actor you attached to the target. If that makes sense.
The actor can't spawn the object
Have it spawn from the player controller.
When you tell me to use widget instead of widget component, it's the same thing no? When I type widget I got that, and when I pass my cursor on it after it say widget component
Can't either, it's on the map by default and if someone drop an item it's spawned by the game mode
Yeah do that. Just make an actor with a widget as a component, vs using widgetcomponent bp. That's the distinction I was trying to make between the two.
So the widget elements need to be visible at spawn, or just when the player looks/interacts?
Only when the player looks interacts
And it's a multiplayer game, and the server see what the client is looking
The client can still spawn actors and attach them to objects that were spawned by the game mode. The actors that the client spawned and attached would be owned by the client.
But that mean that each time a player look for something, I should hide the object only from his eyes, spawn a new one at the exact same location with an UI?
Hmm
If the player is looking straight at something or interacts with it, that would be a good time to spawn + attach the actor that displays the widget, then when the interaction is done, the actor with the widget destroys itself.
At least that's how I would approach it.
Oh I guess I got it
Ok so it almost work, I got this warning and for one frame a new item state can be shown to the server sometimes, or it cancel the shown one of the server if the client is looking it @karmic sparrow
Client interacts with target actor --> Client spawns new actor with widget --> Client attaches actor with widget to target actor.
This should work from the player controller
I didn't spawned a new actor, might be why, gonna try this tommorow
I spawn a replicated projectile from a client then it spawns on all the clients and the server but it is spawned twice in the client which spawned it first so what should I do so that the original client not have two projectile
@summer spade to answer your question in the correct channel...
You can spawn a "fake" projectile on the client, then when the client receives the real one from the server interpolate it to the position of the server's and then delete it.
so you'd really have two projectiles - the fake one the client spawns, and the real one replicated from the server. The client's only exists until a bit after the server's does.
this is the basics of how network prediction works... which isn't a simple task to get right, but this is the gist of what you need to do.
is that a "real" solution? that doesn't seem like it would work at all
i mean i guess it would work for like a bowling ball
it wouldn't work at all for a "real world" shooter
for a projectile based one it would
which is the point
if the time the projectile takes is longer than the roundtrip latency then you just immediately delete the server's projectile when it gets received on the client.
ostensibly the client's fake projectile would have already played out the same effect
the projectile would warp way back and play out something completely different
right, which is why you wouldn't immediately delete the fake projectile on the client, nor would you immediately make the real one visible. To do everything correctly you'd interpolate the fake projectile's movement (but also have to account for server -> client latency, so there will be some extrapolation too).
why bother then though?
because if you don't spawn a fake projectile you end up with laggy shooting. And if the projectile isn't fast enough to beat the round-trip time then you still need to correct for errors.
just let the predicted projectile play out.
Sure, if it matches what the server sees. That's why CMC's prediction system has a range in which it won't correct.
If the projectile is too fast to notice anyway then yeah this is somewhat pointless - just spawn a fake projectile and ignore the server's replicated one.
But if it's not super fast (a grenade would be an important use-case for this since it has a long lifetime) then you'd need to go through all of this for things to look correct.
yeah, I can buy that. I doubt there is any decent game in existence that would do this for e.g. a sniper bullet
Battlefield or arma with very large maps maybe
an RPG in something like that would also probably need this, since if the client is sufficiently off on a large map the explosion of the hit would be in a completely different spot
yeah, it's the old "pick your poison"
Battlefield doesn't really do that [resyncing] [at least not before Bf1]
explosives are such high value events in those games (and usually slower) so it's worth correcting, but bullets, it'd be worse
Yeah I agree that bullets are unlikely
so the TLDR is I should have said "what kind of projectile are you actually dealing with @summer spade " 
It is like a spell
so a slow speed projectile?
Yeah
If it's slow, then you probably need to go through all the stuff I said. Though I'd start with just spawning a fake projectile on the client and not resyncing it with the server yet - get that to work first.
Ok
So spawn a projectile on the client, also spawn one on the server, and come up with a way to ignore the server's projectile (/delete it) on the client that fired the projectile.
see if that's good enough for now. If it isn't, then you get into the complex interpolation stuff.
I think the simplest (and least robust) solution is something like 1) spawn it locally on the client "shooting", 2) spawn a non-replicated one on the server, 3) broadcast an RPC from the server to spawn local ones on all other clients, but ignore it on or don't broadcast to the shooting client. let each client just play their own FX, usually they will match what the server does by luck. damage can either be applied by the server instance or RPC'd up by the shooting client if cheating isn't a concern. if this simple solution doesn't play out well enough due to your game's dynamics then I'd probably immediately switch into doing everything else siliex described
Hey I'm using Advanced sessions etc, And trying to make a simple Players list, to show the current players in the online session. I'm trying to call them through an Array PlayerStates / GameState etc, I have done this in the widget for the current online players, But It seems to be just calling the same client name etc for both. It seems to be getting that there is 2 clients connected, but in the list it is listing the same client name twice for both clients. And only shows the Clients name who is looking at the player list, shows 2 of the clients name.. can anyone think of what might be causing this ? ? Any hints be great. Thanks.
Can we make RPC inside dataasset ?
The second image is pretty cursed
Replicated variable inside of widgets are redudant
And you are getting PlayerController 0
Which is the local player
So no wonder you see the same player twice
You arr already calling set player name
Why the code in thr online player widget?
@sand crown
Also your code will break once the delay in your first image is not long enough
idk followed some stupid tutorial once, was the only thing i could find at the time on making a simple player list, it worked for him, but not for me and now can't even find the tutorial or any other
you already have the player state
I only know about epics tutorial which is garbage
can you by any chance put an example together with a few images ?
I'm not on my pc, so sadly not
Remove the code that is in your second image
That should already improved things
In your first image you are setting the player name
That should be enough
then the create widget won't be calling anything in the first image yeah ?
First image can stay
nono in the BP of their player state
Second image breaks it
@fading birch are you saying to call it in the playerState Event graph ?
Don't get confused
im always confused lol
Yeah leave it. You are creating the widget, settung the PlayerName and then adding it to the list, so that's fine
ok will try
Only thing that i don't know is is how that set playername function is looking like
Cause you didn't post that
that's what I meant by setting it in the player state
not sure if you can do that via BP tho
Not sure what you mean
The Playerstate already has a PlayerName
They already use it in their first image
That's all fine
removing first image code not work,, now just says player name twice.. not getting the separate desktop client info or steam names now.
idk if that is actually set in steam oss
I said the second image
Not first
Also what does SetPlayerName look like?
@sand crown I just realized I have the exact BP setup you're looking for
so. This is my lobby list widget
it's responsible for creating the actually lobby list, and creates a widget for each player by looping through the player state array from the game state
When the widget is constructed, I bind a delegate, which is called after a player joins my lobby
that then calls this function, which creates a lobby player widget, which contains info about the player:
open the original for it to be readable ^
here's what it looks like in action:
In code I am setting the player name: c if(IOnlineSubsystem* Subsystem = Online::GetSubsystem(this->GetWorld())) { if(IOnlineUserPtr UserPtr = Subsystem->GetUserInterface()) { NewPlayer->PlayerState->SetPlayerName(UserPtr->GetUserInfo(0, *UniqueNetId)->GetDisplayName()); } }
@thin stratus i looked through the engine, and I don't think that the OSS sets that at all. You have to get it from the online subsystem
which I don't think you can do in BP at all
ah well will see what i can do. if not I'll have to scrap it
It's not true
The PlayerName is set by the engine
You don't need the oss
You don't need cpp either
My lobby kit on the Marketplace is BP only
@sand crown are you even using that name variable?
I only see you setting it
Is it used in a binding?
If not either bind it or additionally call SetText on the PlayerName text
FString ULocalPlayer::GetNickname() const
{
UWorld* World = GetWorld();
if (World != NULL)
{
// Try to get platform identity first
FString PlatformNickname;
if (UOnlineEngineInterface::Get()->GetPlayerPlatformNickname(World, ControllerId, PlatformNickname))
{
return PlatformNickname;
}
auto UniqueId = GetPreferredUniqueNetId();
if (UniqueId.IsValid())
{
return UOnlineEngineInterface::Get()->GetPlayerNickname(World, *UniqueId);
}
}
return TEXT("");
}
@fading birch
ah ty
I was looking for that
learned how the engine handles from ack handshake -> spawning player though
xD
went down a rabbit hole
// Send the player nickname if available
FString OverrideName = LocalPlayer->GetNickname();
if (OverrideName.Len() > 0)
{
PartialURL.AddOption(*FString::Printf(TEXT("Name=%s"), *OverrideName));
}
FString UOnlineEngineInterfaceImpl::GetPlayerNickname(UWorld* World, const FUniqueNetId& UniqueId)
{
IOnlineIdentityPtr IdentityInt = Online::GetIdentityInterface(World, UniqueId.GetType());
if (IdentityInt.IsValid())
{
return IdentityInt->GetPlayerNickname(UniqueId);
}
static FString InvalidName(TEXT("InvalidOSSUser"));
return InvalidName;
}
I don't generally use listen servers, so i'm a bit lost on how to accomplish this. I want to change the value of an uint8 in my player state. The value is stored as an on rep. I have 2 sets of functions. 1 is a normal function, the other is a server function updates the variable and calls the onrep for it. Nothing appears to happen though.
ListenServer and DedicatedServer are no different in terms of Replication
I would breakpoint and check if your code even calls
relevant code:
.h
UFUNCTION(BlueprintCallable)
void SetTeamColor(ESquishyColour NewTeamColor);
UFUNCTION(Server, WithValidation, Reliable)
void ServerSetTeamColor(const ESquishyColour& NewTeamColor);
UFUNCTION()
virtual void OnRep_TeamColor();
UPROPERTY(BlueprintReadOnly, ReplicatedUsing=OnRep_TeamColor)
ESquishyColour TeamColor;```
.cpp
```c
void ASquishyPlayerState::SetTeamColor(ESquishyColour NewTeamColor)
{
ServerSetTeamColor_Implementation(NewTeamColor);
}
void ASquishyPlayerState::ServerSetTeamColor_Implementation(const ESquishyColour& NewTeamColor)
{
TeamColor = NewTeamColor;
OnRep_TeamColor();
ForceNetUpdate();
}
bool ASquishyPlayerState::ServerSetTeamColor_Validate(const ESquishyColour& NewTeamColor)
{
return true;
}
void ASquishyPlayerState::OnRep_TeamColor()
{
if(ASquishyCharacter* SquishyCharacter = Cast<ASquishyCharacter>(GetPawn()))
{
SquishyCharacter->SetEnumSquishyColor(TeamColor);
}
}```
that was my plan, then I got side tracked digging through the engine lol
Please Review the RPC
Or rather
The normal call
And what you do in it

@fading birch
Also
You might run into a classic race condition with this
Unless your Character also queries the Color
If you have no character on the client at that point, it would never get the color
oh don't worry about that
that's for later handling
we have a bunch of NPCs that follow the player around and change their color to match the player that controls them
Just saying
I had to implement my fair share of customization systems
And it's easy to forget
In the Character?
yes
In the Player Character or follower?
both inherit from the same base
ah
And your Follower won't have that
no it won't
So that needs a custom OwnerPlayerState
Yeah but Owner is Controller or Character
Doesn't mean the PlayerState replicated yet
Best and cleanest would be an OnRep PlayerState variable of the "owner"
the player can't control the minions until they walk up to them
so at that point the PS will be valid
or at least should be
Fair enough
also they're absolutely adorable
What about other clients that join
And the Followers already exist
But the new Client has the PlayerState not yet replicated of the other player
(i hate multiplayer as much as I love it)
so the NPCs are actually spawned by each player
by spending goo (blue stuff on the UI there)
and can only be done on at their base
or a base they take over
Alright, well just making sure you think about all of this. It's annoying to figure out when suddenly a player sees the wrong color

mmhmm
Hi,
We're making a survival co-op experience. When saving multiplayer sessions, would it be easier for the local player to save its characters content (inventory et.c.) and tell that to the server what the player had when joining the session with matching ID, or let the server save all the characters content?
I think saving it on the server is better I guess. Cause maybe the player could change the files saved and could easily cheat.
I am using the GameState and trying to use the PlayerArray at the start of the game. But it is null. I guess it hasn't yet been set by unreal. I tried at BeginPlay() and at PostInitializeComponents() but it's an empty array. What function can I override so that the PlayerArray is set? I want to some set some stuff at the start of the game in the GameState.
@manic terrace Cheating is not a huge issue in this case, since it would just ruin for your friends experience. It's a co-op experience, but I get what you mean π
Thank you for the input
There are a lot of implications with both decisions and I don't think there is an answer w/o knowing your game much better. For example, is it only co-op? Do you always need a server to play or could it get played via couch co-op? How would you handle that a player changes sessions? etc.
@stoic ore No, it's co-op or singleplayer and no couch co-op.
Anyways, I'll elaborate more this afternoon. It's lunchtime for us at the studio.
Hi, I want to stream levels independently for server and clients this works unless a listen server walks into the trigger, then it loads the level for everyone
hi, I haven't been able to connect the plugin to the server side for a week, please tell me how to do this? the "Water"plugin. when I start the server, it requires me to install it, but I do not know what I need to write ((((I really ask you!
hi guys , after many builds and testing of my game suddenly the client that joins the host lags very much when he moves like a tremble and when he pick up an item the item doesnt get destroyed, he keeps adding the item
this is lagswich, in this case, I advise you to put a ping check on a high ping to kick the player
sure but how do i fix that lag ?
maybe a loop causing that lag
does this occur in all players ? or just one?
just the player that joins the host , the host is just fine , and btw that happens only in the built version not in the editor
a very strange event
and it didnt always happen
maybe there are problems with the Internet?
nah i dont think so
i tried to connect localy on the built version , it doesnt lag that much but the bug with the items still happening
@fading birch @thin stratus I had no luck with players list, just keeps calling 2 of the same name.. thanks anyways.
bIsDead = true; if(bIsDead) { UKismetSystemLibrary::PrintString(GetWorld(), "1", true); } else { UKismetSystemLibrary::PrintString(GetWorld(), "2", true); }
I execute this on the server and the 1 gets printed
then I am getting that replicated variable in the animation blueprint
and it should be going to the dead state and play animation.
yea just wanted to test if it was happening because I am getting something weird. The animation doesn't play on the server but it does on the client
and when it plays on the client it does play one the server
I have no idea what's happening I have a listen server and a client. When the server it to be killed the animation plays on the client and not on the server. And when is supposed to die it dies normally both on the server and the client.
Hey guys so recently I've ran into a strange occurrence. So I changed the scale of my player, but after this, some clients would stop spawning. Their user interface widgets wouldn't even show on screen. However, after I moved my 'player start' objects farther from the ground, all clients finally spawned and had a user interface widget. What do you think happened here?
it's likely that they weren't able to find a good spawn area since you're player starts weren't in good locations with the new size.
ah that makes sense. Thanks!
double checked
pawns by default have SpawnCollisionHandlingMethod = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding; set
which the engine falls back to if you don't override the game mode functions for spawning players
or if you don't specify it in your pawn
actors however will always spawn regardless by default
character's use the same default behavior as pawns
forgetting that this is a thing by default for pawns has caused me so much pain in the past xD
Does anyone know if you can conditionally
a) Exclude a component from an actor based on Target (ie. Server), and
b) Choose a different implementation of a component based on Target?
Hey guys im trying to make a function work in multiplayer but it doesnt work when playing on client, works standalone though. the equip function is a c++ function and i tried to make it run on servcer and multicast but that didnt work, or i probably did it wrong idk. could anyone give me some pointers? any help appreciated π
:triangular_flag_on_post: KuShaan_BroSL#0012 received strike 1. As a result, they were muted for 10 minutes.
functions only run on the server
you need to pass through your client-only event to the server by creating a reliable server event
then lastly a multi-cast event
but you have so much going on there im not rly sure exactly how to help, and thats waat makes multiplayer real fun to code! lol
Guys, doesn't own an APawn the PlayerController that have already possessed it? RPCs from the client to a server requires that the client owns the actor where the RPC is being called, and I'm calling my RPC inside the APawn, but the client isn't sending the RPC. EDIT: yes, it does, when the APawn::PossessedBy(AController*) is called, server-side. Since the PlayerController already owns the Pawn, after possessing it, I still don't get it why the RPC sent by the client isn't working, should I do a Multicast, inside the Server RPC scope? ```// Called every frame
void APongGameplayPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if(!MovementDirection.IsZero())
{
const FVector NewLocation = GetActorLocation() + MovementDirection * Speed * DeltaTime;
if(GetNetMode() >= NM_Client)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Orange, TEXT("ServerRPC called."));
ServerRPCMoveActor(NewLocation);
}
else
{
SetActorLocation(NewLocation);
}
}
}
bool APongGameplayPawn::ServerRPCMoveActor_Validate(const FVector& Location)
{
return true;
}
void APongGameplayPawn::ServerRPCMoveActor_Implementation(const FVector& Location)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Orange, TEXT("ServerRPC executed."));
SetActorLocation(Location);
//MULTICAST CALLED HERE?
}```
I just have my own on rep variable and use that to know when the game states variables have been initialized on a client
Hello.. I am working with pixelstreaming and I realized that the pixelstreamerinput component is destroyed as soon as the client loads the server's map. Pixelstreaming keeps working, but I cannot connect to it through the (now destroyed) component. Does anyone knows how can I avoid it, so I can use pixelstreaming in a client-server setup ?.. Thanks !!!..
hello guys i am a new unreal dev and i want to practice in multiplayer vr apps. is there any good tutorials that you could recommend to me?
i prefer blueprints because i am not good c++ programmer
Very broad question, you can make your own, use Gamesparks or AWS services for example.
???
yeah i can see some videos. do you recommend any of those specific? its all the same for vr app?
Hello everyone.I gave my player five choices for a character to choose from.Based on his choice i will change skeletal mesh in that way.When i am changing the skeletal mesh i am doing a multicast then it will change across all clients.But if my player joins late then that player character is not updating it's mesh at all.I also tried setting replication for mesh component but it is not working.Plz help me.Thank you.
I mean if my player joins late then already existing players are not changing their mesh.
put a USkeletalMesh* with OnRep
and set it from OnRep on clients
multicasts are no good if you need to keep state
Hi,
I'm kinda lost on how to solve this problem. We're making a co-op survival experience and when a player joins, they should have had their character variables saved, which is solved.
However, how do I detect which player is who? I've looked into UniqueID in player state, but it seems to change for every session.
Hello, everyone~ I have a problem of multiplayer. How can I send Render image to server from client ? Even I use the "Run on server" and "Run on multicast" , the texture of server is empty but client is existγ
You'd need to send the image as a compressed archive
Compress to png, send it, decompress and upload to the GPU
Agree with @bitter oriole , but try to minimise that as uploading pngs can be very bandwidth draining.
Yeah obviously this would be for like a player avatar at login
But @steep terrace wants to send it from client via RPC to server and I assume server would then re-distribute it to other clients. Just be aware of the costs associated with those actions.
sorry, I am not understand how to upload to the GPU? Is something like Postman or URL ?
My game is a player(using ipad) drawing in the panel, and the his drawing will upload to the computer.
The variable type of Render image is texture. The log said that it is not support when client send to server.
it sound like a good idea ! I will try it! Thx a lot ~ π
about RPC with validation, is the (call)_validate executed on both server and client or just the client?
what do you mean just the client not the server? unreal works with server-client model which means the server always knows what happen on each client
if you are starting to learn about multiplayer there are some useful links pinned on top right corner in this channel, about your question, you have to check replication boxes on blueprints
the one who have to destroy the object have to be the server
I think it's rather the opposite, it's the Server that calls it.
never ever used it haha. I always returned true
There was never a need for it
I did however hear that you would actively kick the client if you return false
Which I'm not sure if that's true, but if it is, then I don't see a lot of things you can place into that
A simple disagree on some ammo value, if the ammo is already replicated, shouldn't kick someone
Guys, my second player/client movement is laggy as hell.To make him see the changes made in the server, through a server RPC, I just called a multicast. But the client movement is laggy. Isn't this snippet the way you normally do? I read in another thread that one solution would be call a ForceNetUpdate inside the Tick, but it didn't solve it ```void APongGameplayPawn::MulticastRPCMoveActor_Implementation(const FVector& Location)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Orange, TEXT("MulticastRPC executed."));
SetActorLocation(Location);
}
// Called every frame
void APongGameplayPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if(!MovementDirection.IsZero())
{
const FVector NewLocation = GetActorLocation() + MovementDirection * Speed * DeltaTime;
if(GetNetMode() >= NM_Client)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Orange, TEXT("ServerRPC called."));
ServerRPCMoveActor(NewLocation);
}
else
{
SetActorLocation(NewLocation);
}
}
}
bool APongGameplayPawn::ServerRPCMoveActor_Validate(const FVector& Location)
{
return true;
}
void APongGameplayPawn::ServerRPCMoveActor_Implementation(const FVector& Location)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Orange, TEXT("ServerRPC executed."));
SetActorLocation(Location);
MulticastRPCMoveActor(Location);
}```
Well
It's kinda the way
But you are lacking all of the movement replication principals
Hello Cedric! Could you clarify this point, please?
kk thanks
You will see two dots
This is a 2D example
but doesn't matter
It's a Server and 2 Clients
You can see the update time on the server (middle)
and 3 settings, as well as lag on each client
If you have none of the checkboxes turned on, you'll notice how laggy it is
That's basically what you have
Now there are 3 things
Prediction: Means that the Client performs the Action while also telling the Server.
You do that so the Client doesn't have to wait on the Position to be replicated to them again.
If you enable that, you'll see that the circle moves faster, but now gets weird corrections
That's where Reconciliation comes in.
This makes sure that the client and server communicate which move they are currently handling.
That means when the Client tells the Server to move, it sends a timestamp along
As well as the result of the move, so the Server can move and compare, and either accept or correct the movement
The correction is what you see if you only enable Prediction
Specially when changing directions
That's because the replicated location from the movement comes back to the client when they are already miles away
Overriding whatever they were doing
Reconciliation makes sure that the client knows what update comes in, and then replays all the moves that are older than that update.
So the correction is if at all minimal and the player keeps moving smoothly
The Interpolation part is only for the other side, so if you see another client you only get the location update, so you want to interpolate between the last and the location
The CharacterMovemnetComponent does all of this for you
If you use a Pawn, you'll have to recode this all
If the text above is hard to understand, start at the beginning of the website I posted you and read through it
This helps a lot to understand what is going on
Thanks! π i need to use the website and read the notes. People in #multiplayer told me, some days ago, to use an ACharacter instead an APawn, but I discovered that I can't change the capsule collision shape without breaking CMC (that would require me to write a custom CMC using a Box component instead, and a capsule collider doesn't fit on a pong paddle), and yesterday they told me to use APawn again. So, I'm cornered: or I rewrite the entire CMC, using a Box component collider, or I code the movement behavior for a Pawn. I'm fucked
@thin stratus there's a good GDC talk on how overwatch handles their networking that covers what you typed as well. Let me see if I can find it
In this 2017 GDC session, Blizzard's Timothy Ford explains how Overwatch uses the Entity Component System (ECS) architecture to create a rich variety of layered gameplay.
Register for GDC: https://ubm.io/2yWXW38
Join the GDC mailing list: http://www.gdconf.com/subscribe
Follow GDC on Twitter: https://twitter.com/Official_GDC
GDC talks cover...
they use a bit of ECS for their networking, which is why the game runs so damn smooth
Yeah that'S up to you
I always try to use the Character
you can sort of cheat it
and have your pong ball react to a certain collision channel
change the collision channels on your capsule comp to ignore that
and then have a box collision on your paddle that blocks it
may be worth a shot @twin juniper
Thanks, I could that for the ball, but I haven't its class yet, is my paddle movement that is laggy XD
no i'm saying on your paddle
just use a custom collision channel
which you can set via your project's properties
Is the free steam app id normally that laggy. Or is my code just bad?
it worth it a try, but in the case of using an ACharacter, right?
once you're in game, it's on you
correct
thanks
so you don't need to rewrite the CMC
let me think how I would do that, and I will post here later
give the pins a solid read/watch.
Replication is a very basic term for working with multiplayer
Could bad replication code make the game laggy? Because I may have some of that or it depends on WIFI?
If you're playing locally and you're having lag it's your code. If you're playing online and have lag it could be code and/or your internet.
I guess I will, for learning purpose, to try to code it, since I have found this thread https://forums.unrealengine.com/t/client-prediction-and-server-reconciliation-for-pawn/46658/4, where a guy explained how movement prediction and correction works (in the CMC, I think) in network games using UE:```/*
Hereβs how player movement prediction, replication and correction works in network games:
Every tick, the TickComponent() function is called. It figures out the acceleration and rotation change for the frame,
and then calls PerformMovement() (for locally controlled Characters), or ReplicateMoveToServer() (if itβs a network client).
ReplicateMoveToServer() saves the move (in the PendingMove list), calls PerformMovement(), and then replicates the move
to the server by calling the replicated function ServerMove() - passing the movement parameters, the clientβs
resultant position, and a timestamp.
ServerMove() is executed on the server. It decodes the movement parameters and causes the appropriate movement
to occur. It then looks at the resulting position and if enough time has passed since the last response, or the
position error is significant enough, the server calls ClientAdjustPosition(), a replicated function.
ClientAdjustPosition() is executed on the client. The client sets its position to the servers version of position,
and sets the bUpdatePosition flag to true.
When TickComponent() is called on the client again, if bUpdatePosition is true, the client will call
ClientUpdatePosition() before calling PerformMovement(). ClientUpdatePosition() replays all the moves in the pending
move list which occurred after the timestamp of the move the server was adjusting.
*/```
I will try the @fading birch approach, if something goes wrong. But I guess I can "use/copy/override" the functions above, and try to use them on my custom Pawn?
And I was thinking, if I want to follow a movement prediction approach like the one presented in Cedric's link, I should assume that the first step to correct the code I posted above is to ```// Called every frame
void APongGameplayPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if(!MovementDirection.IsZero())
{
const FVector NewLocation = GetActorLocation() + MovementDirection * Speed * DeltaTime;
if(GetNetMode() >= NM_Client)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Orange, TEXT("ServerRPC called."));
ServerRPCMoveActor(NewLocation);
}
//Predicts the movemwent that will be validated in the server
SetActorLocation(NewLocation);
}
}```and then I should use GetWorld()->GetDeltaSeconds() value as a Timestamp, to verify and correct the position... To resume it, I must repeat what is in Cedri'cs link and what that guy said (the same thing). How prone to error I would be? XD
The Server RPC should have the NewLocation but also the data to actually perform the move
And then perform the move and compare what the client said should be correct
Thanks for the tip, I will make it work, slowly, but I will: I was reading the Valve article, which was referenced in the link you have posted
Also, in the same article, Now, at t = 250, the server says βbased on what Iβve seen up to your request #1, your position is x = 11β. Because the server is authoritative, it sets the character position at x = 11. Now letβs assume the client keeps a copy of the requests it sends to the server. Based on the new game state, it knows the server has already processed request #1, so it can discard that copy. But it also knows the server still has to send back the result of processing request #2. So applying client-side prediction again, the client can calculate the βpresentβ state of the game based on the last authoritative state sent by the server, plus the inputs the server hasnβt processed yet.is the reason behind the CMC PendingMove list usage, I got it. I guess you guys, Unreal Slackers moderators, are saints, tolerating a bunch of guys/gals coming out of nowhere asking things XD
Besides the Location and Timestamp (as a float), are you talking about the acceleration and rotation?
For example
[2021.07.01-18.37.19:300][646]LogNet: Warning: Network Failure: PendingNetDriver[PendingConnectionFailure]: Your connection to the host has been lost.
[2021.07.01-18.37.19:300][646]LogNet: NetworkFailure: PendingConnectionFailure, Error: 'Your connection to the host has been lost.'
[2021.07.01-18.37.19:300][646]LogNet: DestroyNamedNetDriver SteamSocketsNetDriver_0 [PendingNetDriver]```
Using steam sockets I can't get a client to travel to a listen server map
if I use steam subsystem it works fine
It appears my client is trying to connect to the wrong map
Browse: steam.109775240936920135/Game/Maps/MAP_Startup
but it should say
Browse: steam.109775240936920135/Game/Maps/MAP_MainMenu
thanks!
Is there a way to make HTTPS request from PlayFab cloud script?
Seems like it can only do HTTP.
I have a anim montage replication problem. The montage is playing in the wrong direction for clients (its always facing down towards the ground). The base animation sequence used in the montage is using Additive settings (local space) to get the correct direction (in the direciton of character forward vector, works for the server). I am calling PlayAnimMontage() in a OnRep_Method() to tell the clients to play the anim montage. Any ideas to what I am missing here? Thanks!
Just checking, RPCs should not go through if actor is set to Dormant All, am I right?
That sounds more like a legal issue rather than technical one
I have no idea, I was just wondering if you are asking a technical or legal question. From technical standpoint, it should be doable. But I guess the safest way would be peer-to-server-to-peer
I don't think this is the right channel to ask for legal advice. I believe it is more programming oriented.
AWS has very limited free options, none suitable for game server if you are asking that. "Is it good"? Yes? It's a cloud server of spec you pay for..
Dunno
anyone got problems with session current player count not being updated too ?
What is the equivalent of this node in Unreal Engine 5?
When using the steam online sub system to connect to a listen server, is it normal that by default, the basic character movement replication is not smooth ?
Not smooth in what scenario? Is the owning client not smooth? Server when client is observing it? Client viewing moving client?
client viewing moving client
I believe there is a default client side mesh prediction which should be smooth enough.. I tried it just now and looked fine on my end. Can you send a video of it happening?
sure, let me record one quickly, thanks !
Ha, there is your issue
Paper2D Does not support client-side movement prediction. That feature is only for meshes.
my character has 'replicate movements' on and this is my movement node
argh really ? good to know
Wait wtf, the prediction is dependent on the mesh and doesn't just predict the capsule? That's damn weird.
Yeah, because it needs to handle animations and other stuff
Wouldn't those just be driven by the capsule movement and end up the same either way? Seems like an ass backwards way to do things.
so theoretically, if I replace my sprite with a cube... would that work ?
@shy hill are you based on ACharacter
yes
Does it go Capsule -> Skelmesh -> Sprite?
Try attach sprite to mesh
but right, I don't use the mesh
Its still there tho just empty
If that's the component being predictably moved then attached components should follow. Try it.
Although common sense goes out the window when dealing with the CMC
still a bit laggy, but definitely better π
thanks a lot, that already help a lot, I spent many hours trying to figure it out :d. My concept relies on pretending to be an NPC, so ideally there shouldnt be any lag at all, if you have any tips to improve it further, I'd be happy to here them (I tried 'smooth sync' but it came with other issues I couldnt solve )
what is the Proper setup for Dedicated server testing? When I use the editor and run 'clients' they behave differently to when I package a dedicated server build and the run it. It's a pain to have to have to package client/server every time I make a small change, what is the best way to go about this?
You can run servers standalone too
Might still be slightly different to how packaged behaves though
But removes the need to package
Most studios set up buildmachines with jenkins and p4 though to automize stuff like that
so if I make a small change to a blueprint how do i run the server standalone?
you mean i jsut dont package?
you can make a shortcut like this:
"EngineLocation/UE4Editor.exe" "ProjectFolder/ProjectName.Uproject" -server -log```
ah ok cool
then is there a way to run a client like that too
instead on in editor?
yes. replace -server with -game
excellent, thanks so much
Hey. I also found this post from searching for "turn in place jitter". Did you ever figure this out? I'm having the same problem
Yes, iirc it had to do with the order in my animBP for tip and spine rotation
If I randomize materials and pass it to SetMaterial to my Mesh in BeginPlay, do I have to replicate this?
Does anyone know or have any pointers on how to implement spectating teammates like in CSGO or Valorant where you basically see your teammate's POV
Having issues with a flying vehicles location being incorrect if it collides with something
anyone have any suggestions?
they're just completely off lol
@oblique bay I dont know those two games but I think the easiest way would be to setviestargetwithblend on the teammate's pawn.
If you want it as part of the HUD instead of changing the entire viewport over, you can do that with a scenecapture2d on the the team mates pawn and a render target as your texture on the hud widget.
But if you want the exact view the other player has as a picture in picture in your HUD including THEIR hud, then I am not sure how to do that.
I think for most use cases you wouldnt need any network code to do it though
Unreal Tournament or Shooter Game might have code for you
Hiho, what exactly is better to have a fixed game mode and to regulate everything via a game mode or a parent game mode and some child game modes?
Master Game Mode (Main Game)
MenuGamemode (Login Menu)
ThirdPerson Gamemode (everything about the player / character)
or
MasterGamemode (for everything)
Someone have any ideas? ^^
Maybe a bit too specific question, but does anyone know why actors gathered by UReplicationGraphNode_DormancyNode are not network culled based on distance later on?
That's probably true, I also think that it serves as an overview, there are also aspects such as widgets that should run on the client in the third-person game mode (widget = client) and other things such as the status values, strength of the opponents, etc. server-based so that nobody can cheat ^^
I would always tend to having proper Hierarchy
I would never want my GameMode for the MainMenu to have Gameplay Code
Neither would I want MainMenu and Gameplay Modes to have code for Lobby etc.
someone can always cheat
and until you have a functional game you shouldn't even try to account for that
I agree with you, but client-based data is always easy to change, while data on the server is always freshly accessed and cannot be influenced by changes to the client.
I have a little problem and hope someone can explain how to fix my problem.
I know that widgets work at the client level and not work at the server level.
What exactly is the difference between a widget and a UI?
How can I fix this error that when I press "i" to open the inventory, the inventory also opens?
Before the switch to "Play as Client" everything worked ^^
Do you mean this should not be in the ThirdPerson gamemode??
ah ok
Check the pinned compendium
GameMode is server only. Clients would never get a widget
If you are trying to access GameMode from your GI on clients, that would not be allowed either
tho i cant tell what those errors are doing
i can tell you
pls give me a second ^^
wow
Ok i have deleted the Create Main Widget from the ThirdPerson Gamemode (no Error) and copied the code into the ThirdPersonCharacter (now i have Errors) xD
@meager spade Ok can you explain why i get this error Code?
this is in the ThirdPerson Character
I didn't get any errors when the same code was still in gamemode.
The same Error Code in the game Instance...
just dropped by: @merry harness dedicated server?
Yes Play as Client
iirc, dedicated servers cannot create widgets. So if your code is ALSO running on the dedicated server itself, that could be why
The main Menu isnt replicated
And the Main widgted Event /to create) ist only run as client
So that's exactly why I have all the stuff in the MasterPlayerController. I told every event there that it could only be carried out on Cliets ...
should i have the shortcuts also into the MasterPC?
These are in the ThirdPersonCharacter
someone have any idea?
What would be the best way to set the rotation of an non-gameplay relevant thing for each player ?
As in, Object 1(Which exists for every player) should always look at the "local" player
Might make more sense if i explain the situation.
My enemies are having a UWidgetComponent which will show a widget with his health and similar above his head.
And i want this widget to always look to the player on his client
On Beginplay, find the local player... then on tick, Interp to Local player find look at rotation? ^
Finding the local player is kinda my problem here ^^"
GetWorld()->GetFirstLocalPlayerFromController() is the best i found, but even there i have no idea how to get the character from ULocalPlayer
Oh, seems like it has a PlayerController variable
Just putting it on ScreenSpace isn't enough?
I feel like there is a way to avoid the NetMulticast here, but i'm not sure how.
This here is my TakeDamage method
void AEnemyBase::TakeDamage(const FWeaponDamage& DamageAmount, APlayerCharacter *Causer)
{
if(M_AttributeComponent->GetIsDeath()) return;
//Damage calculation...
if(M_AttributeComponent->GetIsDeath())
{
Server_HandleDeath();
}
}
Server_HandleDeath Is basically just this here
void AEnemyBase::Server_HandleDeath_Implementation()
{
HandleDeath();
}
void AEnemyBase::HandleDeath()
{
GetMesh()->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
GetMesh()->SetSimulatePhysics(true);
}
But this whole logic doesn't seem to work on the client
Client should never call that
Neither should there be a serverrpc in that
Server rpc should happen waaaaayyy earlier when your client performs their input
Unless this is a Multicast
I'm sadly still a bloody beginner when it comes to networking π
Then you mislabel it quite hard haha
You should always remember that state changes should be done via onrep variables
Not multicasts
Being dead is a state change
Make it an OnRep Boolean
I've tried to make a OnRep method with M_AttributeComponent, but it didn't even fire
It will fire automatically clientside
If you also need it on the server then you need to call the Onrep by hand when you change the variable
I've tried it with a debug message, but it was never called.
Can it be that it's cuz M_AttributeComponent is a more complex type than a simple struct ? (It's UCharacterAttributeComponent : public UActorComponent)
I don't follow. If you have such states in a component then thr component itself in additon to the actor has to be marked as replicated
And then you would have the Onrep boolean in that component
The pointer to the component doesn't need to be marked as replicated. Component is spawned in construction on clientside anyway
Phone is dying soon. So might stop answering
Oh, so i should basically get the OnRep notify within the UCharacterAttributeComponent class and in case IsDeath will be changed to true i'll call the HandleDeath method from the AttributeComponent ?
Argh, wish my brain would be quicker when it comes to networking
@vague fractal is there a reason you're not using virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser); ?
Yes, i've heard it's getting deprecated in UE5
Ok noone knows..
where'd you hear that from? It's not marked as deprecated in the early access.
Several ppl told me that
Yeah, sry for my question flowing down your question π
you don't need "Run on owning client" as a an RPC for widgets. A simple check of role on the controller will suffice.
Without seeing how your inventory component toggle works, we can't help you
you should probably ask in #umg as this isn't a multiplayer related question
i'm staring right at UE5 source and not seeing it marked as deprecated, so 
It seems trust worthy to me if even Siliex* claims that it was said in the patch notes
#cpp message
Ok i thought its multiplayer because the widgets are working ijn singleplayer (with out server) Thanks ^^
The damage stuff is de facto deprecated even if it isn't marked as such. It's a bit odd that they're not deprecating before removing, but UE5 is as good a chance as they're going to have to make breaking changes so meh. It's likely something coming with the full release at this point (or maybe a future EA). I haven't checked if the main branch has removed it yet.
Damage stuff still exists in ue5-main for now. So they haven't removed it yet. Or the migration guide is entirely wrong and they changed their minds on removing it.
hey guys, how would I go about replicating flashlight's pitch? I got something like this, but the spot light pivot is kinda screwed up and it doesn't rotate properly, could you help me out?
you would think they would at least mark it as deprecated
You also think they would have proofread the migration guide.
Obviously something is wrong there, for now I'd assume it's going away.
I posted this in #virtual-reality but I really need some help doing Oculus VR multiplayer
anyone able to do this?
Well here's the main issue
I have only ever made singleplayer games
but, that being said
there is zero documentation about VR replication
Well, there's tutorials showcasing them turning the first person and third person tutorials into Networked apps
I'm just looking for something that has to do with VR replication because the motion controllers are apparently different
Well again that's the issue
I'm going off what I've read here
I'm just not even sure where to start, because there's nothing to follow rn regarding this
I think i found some lead
but i'll have to see how it goes
speaking of VR, is there a good way to test two VR players by yourself?
Not really, we have 2 Quest's just to test on Oculus π
I'd almost recommend making a non-VR mode just for testing game features.
it's a bunch of extra work but... it doesn't need to be polished and you might make that time back with improved iteration speed on anything that isn't directly tied to motion controls.
ugh, damn
Anyone know what would cause this error in a packet?
We're using BP over C++ for simplicity
Hey all, when trying to build a dedicated server to test out my project that I have been working on in Unreal with multiple people, the build time for all of the files has taken significantly longer (about 10 hrs) than what the github page estimated for it to complete. So, I was just curious as to if this could be because of my hardware specs and not being connected to ethernet or if it could be because of an ulterior reason.
Build times are based entirely on your hardware, primarily your CPU
but iirc you can just launch the server from the client exe with -server
Collection of arguments that can be passed to the engine's executable to configure options controlling how it runs.
@mossy lantern were you building the engine from scratch for the first time?
A normal first build time for a dedicated server can take anywhere from 10m for an empty project to 2+ hours for a larger project
our Build machine takes ~30m to build an updated version of our dedicated server and that build machine is bonkers fast
in addition to what @severe tendon linked, you can also do this:
make a shortcut like this:
"EngineLocation/UE4Editor.exe" "ProjectFolder/ProjectName.Uproject" -server -log```
I usually create a shortcut off the `.uproject` file and then construct that in notepad and paste it in. `-log` is especially useful beyond seeing a log because if you close it, the server also closes. If you don't have `-log` you'll need to close it via task manager
Does someone have a solution for the choppiness when two character colide while moving with latency?
So I should expect my character to teleport when someone move into them? I know the plugin, I use it when I need to use physic.
It work very nicely when I disable the network simulation
Movement and colliding is physics
The reason its so choppy is because of the server and client positions not being exact, Client thinks the server object is at Pos 1 when its at Pos 2, so smoothing should fix that as far as Im aware
I'm going to give it a try, I was more hoping about something simple to setup in the CMC networking panel
Sadly it's true, smooth sync just resolve it. I didn't wanted to use it, but that just seem impossible without it
Thank you for your output
Yeah I was building it from scratch for the first time and ah okay interesting, I'll make sure to try that. Many thanks to you and @severe tendon .
building the engine from scratch is expected to take a 30m - 4+ hours.
depends on your CPU
quick question: at which point does an actor class has their network role established? Ctor? OnConstruction? PostInitialize? BeginPlay?
constructor
AActor::AActor(const FObjectInitializer& ObjectInitializer)
{
// Forward to default constructor (we don't use ObjectInitializer for anything, this is for compatibility with inherited classes that call Super( ObjectInitializer )
InitializeDefaults();
}
void AActor::InitializeDefaults()
{
PrimaryActorTick.TickGroup = TG_PrePhysics;
// Default to no tick function, but if we set 'never ticks' to false (so there is a tick function) it is enabled by default
PrimaryActorTick.bCanEverTick = false;
PrimaryActorTick.bStartWithTickEnabled = true;
PrimaryActorTick.SetTickFunctionEnable(false);
CustomTimeDilation = 1.0f;
SetRole(ROLE_Authority);
RemoteRole = ROLE_None;```
I did check that but that doesn't seem to account for networking specifics.
what do you mean?
Well, this seems to be before say things like simulated copies get their roles assigned
Anyone know why a client leaving a game would not tell the host they have left?
{
if (UOnlineSession* const LocalOnlineSession = GetOnlineSession())
{
LocalOnlineSession->HandleDisconnect(World, World->GetNetDriver());
}
else
{
GetEngine()->HandleDisconnect(World, World->GetNetDriver());
}
}```
this is what i call when a client clicks the quit button, but they end up not actually leaving, but the server will time them out
I've had that issue with Connect/Leave, I ended up just writing a jank 5 second timer that checks if there are more actors of the player type in the level than there are in the array of active players and then if there are more/less then it removes them and updates the server.
I still can't figure out how to actually have it update π
I have this weird issue.
I have some UI set up where players can choose their loadout. When they save what loadout they want, that information is stored in the player's Player State (it's just an array of "gadgets").
The first player spawns. No worries- the gadgets he chose are there, and he can use them.
However subsequent players that choose their loadouts will spawn with their gadget choices in addition to the choices made by the previous player.
For example, if the first player chose a smoke grenade and a flashbang...
And then the second player chose camoflauge and extra ammo, the second player will end up with all four gadgets.
What... what could be going on here? It's like they share a common PlayerState
No idea without seeing your code.
void ASpy::InitializeEquipmentBasedOnLoadout()
{
if (SpyPlayerState)
{
if (SpyPlayerState->GadgetArray.Num() > 0)
{
for (int i = 0; i < SpyPlayerState->GadgetArray.Num(); i++)
{
TSubclassOf<AGadget> Gadgetclass = SpyPlayerState->GadgetArray[i];
FString GadgetName = Gadgetclass->GetDefaultObject<AGadget>()->GetGadgetName().ToString();
UE_LOG(LogTemp, Error, TEXT("You have selected: %s"), *GadgetName);
if (InventoryComp)
{
InventoryComp->AddGadgetToInventory(Gadgetclass, 1);
if (bShowDebugs) { UKismetSystemLibrary::PrintString(GetWorld(), TEXT("Spy.cpp - InitializeEquipmentBasedOnLoadout() called.")); }
}
}
}
}
}```
From the PlayerState BP
The UI that adds the gadget array to the playerstate
Might any of that help explain what the heck is going on here?
As i said, the loadout works great, but it's like they're.... sharing a player state
This is called from the character to take the gadgets from the player state and equip the player with them
Yeah???
You can't use that node in Multiplayer like this
If you call this on the Server, which you are
Then it's the Server's PlayerController
And thus the Server's PlayerState
..... and that would make perfect sense
Locally you can use GetPlayerController0 if you have no local coop stuff
So e.g. in the Widget
But not if you start communicating between players
Where is that Server RPC in?
In the PlayerState
That server RPC is in the PlayerState BP
Why do you get the PlayerState again from the PC?
You are already in it
It might even be the correct one
... good point
The SecondImage is fine-ish
But even here you should probably use "GetOwningPlayer"
And make sure you pass the PlayerController into the CreateWidget Node
Okay amazing I'm going to try and implement this right now
The third image looks bad too
In the Character you can do "GetController"
Or even "GetPlayerState"
Not sure why you use GetPlayerController0 here
That's again the Server's
The PlayerController creates the PlayerState, so in your Character you can just use the OnPossessed event or whatever it's called, and do "GetPlayerState" and get the Data
Taht event calls Server side only
I assume you want to spawn gadgets server-side only anyway
Something like that
Thank you! I'm going to try and get all this in and see how she works
Re this image.... this BP code is from the Character's BP, not the player controller. I can't seem to access the Event OnPossessed from the character, even if I try to from the controller node
AH, okay found it here
Hmmm yeah the loadout system doesn't work for servers or clients at all anymore
Yeah not sure how the rest of your code works
But given what you posted this should be enough
I assume the Loadout selection and the Spawning of the Character happens after each other and on the same map
Yes, spectator pawn is possessed, player chooses their gadgets (held in the player state) then clicks spawn - player spawns with their gadgets loaded in from the player state
PlayerState (new)
from the Widget blueprint when they save which gadgets they've chosen
Called by the character's BP
Where is this done? This doesn't look familiar
Where you Create the widget
So this is from the controller BP..
Everything else I think seems to be working, but when I try to add my UI, it causes a hard crash. I'm guessing there's a conflict between the 'Possess' event on the player character and this 'On Possess' event? Perhaps? If I disconnect the UI from being created/added to the viewport, it doesn't crash
Yes... so above is causing a hard crash but I think the rest of the functionality is working..
When the UI loads in, it crashes
You can't use pins like this
Only because the EventGraph allows it doesn't mean you can pull wires as you please
If you need a Callback to add UI that depends on the Pawn
Then you should use C++
There you have the OnRep_Pawn function you can override
The ClientRPC obviously would work in terms of calling, but you can't bes ure that the Pawn is available on the client yet
And if you want the pawn, just use GetControlledPawn
Don't use the PossessedPawn pin like this
You are moving between Networks, the Client has no idea what the value of that pin is
@odd sundial
@thin stratus Appreciate all your hard work here!
Yeah I can't get.... around these hard crashes because of the UI. Ughhh I'm so tired. I give up for now... thanks for your help
we have a real time multiplayer online racing game ...
our dedicated server has 16 core cpu and 16gb of ram ...
how many players can this server support simultaneously?
Yeah nothing we can answer. You'll have to profile it yourself and then judge.
I was wondering why the default Net Update Frequency which is a 100 is that high. Isn't that just too much? I have mine to a value of 5 and from what I have seen so far it is working fine. I changed it on my character and haven't seen any dramatic changes. Should I have it higher?
For multiplayer is it better to make a single player game, then convert it to multiplayer or to make it with a multiplayer framework to begin with
Thanks
At the end of my race I need to send a ghost structure to the server. The weight of the struct is 244kb, in your experience is this a high number or is it ok? my first time with server stuff π
after serialization
Quite large for a one-off packet, but might go through ok
If not you'll have to spool up a socket
is there any 'standard' size to take as reference? I know it may be a silly question, I'm trying to understand π
IIRC the default "saturation" limit in 4.26 and above is 100kb, but that's for a full seconds worth of data
UE's networking is designed for very small packets at high rates
ok thanks a lot
Epics recommendation BTW is to use sockets if you have to do this
got anything that I can read about this?
Hi @ all
I trying to replicate a physics actor. Can someone explain to me why this is not possible with my settings? I spawn the balls on the server but on the clients it have different positions
The Actor also needs to replicate movement
But be aware that this is not smoothed at all
And that Replicated Physics shouldn't be used for Gameplay, as physics aren't deterministic etc.
@thin stratus
How would you do such gameplay in principle? Are the physics in games like rocket league or fallguys fake?
Rocket League has done a lot of additional work to get this working
There is a youtube video about it, obviously not detailed enough to easily copy it
Fall Guys is not UE4, or?
relatively sure that's unity and also kinda sure that they had to do a lot of groundwork to get this working
it's Unity
@thin stratus
I am a programmer, but no C++ so far π
. If this means a lot of work, I'll have to rethink my gameplay. My plan was to have small races with mini-games in between, but it looks like I will have to cancel the mini-games. It's just a hobby project π
@fallguys: oops i always thought that was the Ue4 but Djriff is right it is unity
Yeah it might be a lot of extra work
At least if you want the players to have a good experience
I was pretty surprised it was made with Unity
Unity is a fine engine, but the marketplace makes me run away as far as possible
it's a sad state
We use your network guide all the time Cedric. Thank you!
Glad it helps (:
@green spoke
@thin stratus
Yes, the best guide for repication! thanks alot
i'm not familiar with that
ah
Is it a bad sign that the physic body's aren't 100% sync ?
I'm kinda afraid that it could break my interaction system since you have to look at the dead enemy to loot him
replicating physics is a nightmare
hence why you don't care where a dead body is (if might be slightly different place/position on eveyr client)
but why does that matter?
I was just afraid that the server might think Hey, you try to loot an enemy here, but there is no enemy at the place you are looking at
client can just tell the server hey i wantr to loot this
Alright, i'll try to ignore it then ^^
Currently it's anyways already like 95% sync (Likely wont last for long xD)
Until it all falls apart with high latency D:
Also, are there any VR devs in here? I was wondering how people deal with room scale and multiplayer, it seems like an insecure and weird mess to me π€
Especially when for example already dealing with the Character Movement Component. I have for example been trying to support room scale for a test, but my clients keep desyncing because I try to move the actor to the camera, which obviously the CMC doesn't like. But even that is still a very insecure way and not something you can correct if it goes wrong on the client (a desync). I really wonder how games like Pavlov deal with this.
Room scale refers in this case to the person in VR physically walking inside their own real life room, so if I walk 1 metre in the real world my camera will also move 1 metre relative to the actor. Why I move the actor towards the camera is to make sure the collision of the character (the root capsule component) stays relevant for.. Well collision. This makes sure people can't literally walk through for example walls in the game. But at the same time like I said this solution is really not cheat proof and to my knowledge also not a good way that can be corrected by the server if the client does desync from the server.
The cheating aspect would obviously be, who says a client doesn't make speed / teleport hacks out of this? They could say the camera is suddenly 20 metres in front of them, you could only really do checks with this such as "Isn't the camera maybe 20 metres away from the original centre of the room?" or "Isn't it moving literally metres per frame?" etc.
I'm not too worried about hacks though, but I would prefer a client not having really weird issues if they for example maybe lost track of the headset and the headset suddenly teleports all over the place or goes to a 0,0,0 relative location π
It's weird a feeling correct, but there are many games that don't allow this by pulling back the player camera (which is what I described). Which isn't an ideal solution, but better than walking through a wall and possibly getting in the most weird places if you would ask me. But fading to a black screen is also a solution yeah.
Is there maybe any good guideline for when to use what(As in when should i use OnRep, when should i use a Server RPC, how do i call it ect..) ?
I feel like i'm doing everything wrong while it still somehow works.
Welp, i guess i should just buy a course like that one.
If anyone ever tried that one, would be really cool if you let me know if it's good π
https://www.gamedev.tv/p/unrealmultiplayer/?product_id=1500305&coupon_code=JOINUS
https://learn.unrealengine.com has free courses @vague fractal
i think it may also have that one for free.
Since when did they added this?
And does it work well? Are there any additional steps?
Hello everybody
I have a multiplayer game that I load sub-class of my gameβs character from a data asset when a player connects.
I want a recommended way to spawn this character and possess that on the controller. Currently, Iβm using On posses but I think there is a better place to do this.
Wow Epic! Lol why did they put that in there.
I heard UE5 gonna support 64 bit world coordinate, what do you think?
hopefully simple question (my google-fu seems to be failing me on this one, im probably searching for the wrong term) but in the context of something like a multiplayer shooter (and in the context that i'm a hobbyist noob and still dont know the nuances between some of these items), should input be handled on the character or should I make a playercontroller? Should I make my character from the unreal character class or the pawn? Any recommended resources for learning more about why I should do one or the other or how to properly implement a player controller?
Oh great!
How would I avoid using multicast in places? what are some conditions where I wouldn't need to use multicast? (I don't need like a 100% rundown, just like general rules would be the most helpful)
Ok I guess my confusion is, I created a character and bound input axis and actions. But I did not create a controller, is it creating a default controller that I should edit? Is that where those input bindings should actually live?
@modest rune Your GameMode has the default classes for those things. The Engine will use the UE4 default controller class for possession if you have not specified your own in GameMode. As far as input bindings, you should put them where they're meant to go. This heavily depends on your game and personal design, but a good example might be something as simple as a tab button to open up a typical shooter's game stats page with KDA stuff, game time, etc. This should probably live on the controller, since you'll likely want players to see this when their pawn is dead, or even before it's spawned. Movement should most likely go on the Pawn itself because you can't guarantee you won't create different pawn types. Classic example is human versus car/horse. Car/Horse will have majorly different controls than a human pawn, and having to route that through ifs and branches in logic is a headache that can easily be avoided by keeping the input in the pawn that uses it and possessing them correctly.
Does anyone know if GTA V use deterministic physic or semi like default Unreal?
Guys, I'm passing a USTRUCT as a reference in a server RPC, but, for some reason (probably is something I'm missing), the reference isn't working. If I discard the struct and use its member as the RPC parameters, directly, everything works fine. Here are the snippets:
USTRUCT()
struct PONGONLINE_API FMovementPredictionData
{
GENERATED_USTRUCT_BODY()
private:
friend class APongGameplayPawn;
float Timestamp;
FVector Location;
};
(...)
UFUNCTION(NetMulticast, Reliable)
void MulticastRPCMoveActor(const FMovementPredictionData& PredictionData);
UFUNCTION(Server, WithValidation, Reliable)
void ServerRPCMoveActor(const FMovementPredictionData& PredictionData);```
What is wrong? Should I use the UPROPERTY(Replicated) in every USTRUCT member, even if the struct itself isn't a replicated property and is passed in a RPC?
anything you want replicated in a struct needs to be UPROPERTY() (not Replicated)
Thanks, @hollow eagle ! The compiler just told me right now: ``LogCompile: Error: Struct members cannot be replicated```
read what I said again
? Should I only mark struct members as UPROPERTY, and not as UPROPERTY(Replicated). Did i misunderstand it?
correct
struct properties are replicated together, they aren't opt-in like a UCLASS property.
Thanks, let me test this, because I don't now if the lack of UPROPERTY in the struct members was the cause of my issue
Yeah, it was π Thanks @hollow eagle
you can opt out certain variables from replicating if you want in a struct
Has anyone ever extended the CMC ServerMove RPC Functions?
I tried that a quite some time ago (probably 2 years ago or so), because I needed more info from Server to Client than there was available. But I think it wasn't really working.
If someone did that, are there any "here is how it should be done" posts?
Because the Wiki entry that explains how to use SavedMoves does it wrong. They just RPC the extra data in a second RPC, which is of course not synced to the ServerMove one.
Base ideas would be adding custom ServerMove functions, adding either the specific parameter or a struct that properly net serializes to them and using those instead of the default ones. +- copy pasting a shit ton of code because the CMC has too big functions with no options to easily place code in between
I'm aware though that 99.99% of the time, the Server most likely has all the data it needs to perform a move, so the flags for "I want to do XYZ" are enough.
I've always just modified the CMC code
it irks me that stuff isn't marked as virtual
forcing you to use source
you mean in a custom engine
yup
you can technically get around it
with a few redirectors
and just copy the entirety of the CMC
I briefly toyed with that today
as i'm doing an engine upgrade, and had to copy over our CMC changes
Yeah that's also all fine. The "How to make it work" is not what I'm interested in
I know I can make it work. I would love to know what the best way is in terms of implementation of the additional parameters
E.g. by default this is the server move signature:
ServerMove(float TimeStamp, FVector_NetQuantize10 InAccel, FVector_NetQuantize100 ClientLoc, uint8 CompressedMoveFlags, uint8 ClientRoll, uint32 View, UPrimitiveComponent* ClientMovementBase, FName ClientBaseBoneName, uint8 ClientMovementMode);
The CompressedMoveFlags is the only info we can additionally send along
e.g. "User pressed key"
Like Jump or Crouch
but what if I want to say "User pressed Key, and wants to perform this action with these values."
"these values" have no place
And if the value is only known in the frame that the user performs the action, then the Server could not be in sync
An easy example would be if you want to jump with a different strength
I can edit JumpZ runtime, but not without an additional rpc
I mean, it goes against the design to let the client specify those values, but if cheating is not a concern then who cares :D
I also don#t have enough custom flags to even specify multiple different actions -_-
this was the exact issue we had
and why we had to modify CMC
I'm sorry I don't have any answers for you, i'm still neck deep in this engine upgrade otherwise i'd look into it. If you do find out, please share as i'm interested in that.
It's not urgent. It's just a thing that comes up every now and then and I was curious if others solved it
If I get some time, i'll look into it this week
but my plate is pretty full both on and off the clock unfortuantely
I have next week off though
π
Buddy, that's your free time. Enjoy life. Don't look into this sh't for me :P
hey, i want to know too xD
i'm like a sponge accumulating semi useless knowledge that serves me no purpose, except to pass onto others
You'd be surprised how much it's worth to know a lot of stuff, even if not very in-depth
it's saved my ass a few times actually
surface knowledge is like gold
especially in this industry
enum CompressedFlags
{
FLAG_JumpPressed = 0x01, // Jump pressed
FLAG_WantsToCrouch = 0x02, // Wants to crouch
FLAG_Reserved_1 = 0x04, // Reserved for future use
FLAG_Reserved_2 = 0x08, // Reserved for future use
Those have been reserved for ages. At this point they could just make them custom too
Whatever they are going to add is doesn't even need to be of any value to me
E.g. like what if my character doesn't freaking crouch
:/ c // Bit masks used by GetCompressedFlags() to encode movement information. enum CompressedFlags { FLAG_JumpPressed = 0x01, // Jump pressed FLAG_WantsToCrouch = 0x02, // Wants to crouch FLAG_Reserved_1 = 0x04, // Reserved for future use FLAG_Reserved_2 = 0x08, // Reserved for future use // Remaining bit masks are available for custom flags. FLAG_WantsToSprint = 0x10, // Wants to sprint FLAG_WantsToSlowWalk = 0x20, // Wants to walk slowly FLAG_SlidePressed = 0x40, // Slide press FLAG_Custom_3 = 0x80, };
we didn't touch them
Β―_(γ)_/Β―
we were worried about the future
cause you know
these have changed in the past 10+ engine versions
Since it's my first time with server/multiplayer stuff, what is the best way to compress ghost data (struct of rotation and location)? I'm doing the serialization to json but I don't know if it's the best
hey was wondering if anyone could help with this im using the advanced vehicle system demo project and im trying to set the visibilty of the 3rd person character to hidden when they enter the car
and its meant to be for multiplayer - but whats happening instead is that on the client both players are invisible as is meant to be, but on the server the server player is hidden and the client player is visible
so... from the server u see the simulated proxy visible?
i have no idea what that is not going to lie
hahaha
let me check if I can find any resource explaning what that is
its essential to understand multiplayer
hold on a second
A static site pulled from the internet archive
take a look on the roles section
the quick review of roles?
mhm, but I think its explained a bit too complicated
boouf yeah it's explained a bit complicated everywhere
yeah im not getting it from reading that tbh
but i do know that i tried to do the hidden in game through a custom event on the server and through a multicast
so ill make it simple
and it had the opposite results
yeah
that's a simulated proxy
now authority is wether you are on the server or not
and autonomous is your own client version of self
there is a bit more into it and its a bit unaccurate but I think it can get you to start grasping concepts
so if you are playing with your friend
and you want to make him invisible just for you
you need to grab this simulated proxy and make it invisible
got it?
yeah
nice so what is happening then?
explain me your problem using this terminology
so lets see if we can figure out together
ur simulated proxies are visible?
so in this screenshot im setting the simulated proxies to invisible once they enter the vehicle -
okay but you would like to set also the autonomous and authority versions to invisible
it works on both the client version for itself and the server version for itself - in the client version the server player is also invisible however in the server players perspective the client player stays visible
so from authority
your simulated proxy is visible
where did you set this hidden value?
server or client?
server
okay so if you want everyone to acknowledge that visibility
you'd need to multicast it
assuming that visibility isn't replicated (I guess it isnt)
im not entirely sure on what you mean by that everything from the other player their nametag and vehicle they drive and stuff is replicated and both players can see
no haha what I mean is that some variables on the character are replicated underneat (that you cant see)
so rn I dont know if visibility is or not, because if it is replicated it might work just setting it on the server
but since I guess it isn't
you should multicast it
Probably super blind here, but i can't seem to find anything with the keywords Multiplayer or Networking π
thats a multicast yeah. It will execute everywhere, including where is launched
and this is the result - the smaller window is the server player and the bigger window is the client player
the client player is behaving correctly the way i want it - both players invisible in the car
but you can see the client player there in the car on the server side
From what i've learned so far it should be a case for the OnRep method
so do another custom event on server?
he doesn't need a variable for this
no
just add the sethidden
right after the multicast
so you do the multicast and the call on the server
thats done here
no
I mean, if that means that he have to use a multicast it sounds like a variable is better
irs essentially the same however a variable onrep adds the overhead of having a variable
:)
And the multicast might not even fire for clients where it isn't relevant
so doing this
yeah
same result
the client player is visible for the server side player
but both are invisible for the client player
are you sure this is all execd from the server?
this blueprint is a function for the interact button
for the player
is that literally why... klsjadjksadls
...
its okay you are learning
so you need to carry this action to the server using an rpc
and then once you are on the server you can multicast
although from authority that will essentially be the server
although. Listening yo @vague fractal lets follow good practices and I'll explain you next relevancy
because that's another networking concept you need to understand
relevancy means wether an actor should care about another actor over the network
the less actors an actor has to care about
the less traffic
got it?
sooo
one of the techniques we can employ
is turn on relevancy based on distance
if an actor is so far from you
why would you care about it?
thats what network distance culling is
once they are in range you start to care about them
so what happens is...
if some property of your actor has changed while it wasn't relevant for another actor
once it becomes relevant your other actor has to see this property changed
if we use multicasts that wont do the trick
:(
we need to use onreps!!
so as Yinsei pointed out in a smarty pants move
is that "what about relevancy?" well, he was right
if we want this visibility to change when we have relevancy changes we better create a flag variable that will be in charge on performing an action every time it changes
this type of variables are called onrep
so once you have carried your action to the server
you can have a visibility onrep variable on which you execute the sethidden code
aand
it will work like a multicast (just in blueprints, in C++ is different)
gotcha thats just a way of doing it thats less taxing i suppose
not taxing
just more appropriate
because with multicasts you aren't defining a state
with a variable you are
therefore
multicasts in general are just for visuals
non important stuff (please artists dont kill me)
an onrep is to define a state
that will react accordingly with an action once the state is replicated
gotcha
its working now that i've changed it to be on server now tho cant believe i didnt realise that lmao thank you for the help and teachings i shall try to put them to good use
:)
if i want to do sprinting and not have jitter from server correction will i need to do it in c++
because every blueprint implementation of sprinting in multiplayer i see fails miserably when lateancy is involved
I think the problem here is that you can only override some CMC related stuff via C++, but i think a simple sprinting should be possible with BP only
like ive tried diffrent tutorials for multiplayer sprinting and even tried a project from the market place but they all fail as soon as i introduce a little lag
only thing ive got to work was someones c++ project
How would you make it work via blueprints? At a guess, I imagine the problem with jittering comes down to the fact that you need client-side prediction and server corrections
more specifically the server needs to be willing to accept the client's predicted actions and apply them retroactively
yeah only solution ive found is to do it in c++
default CMC does that, but any naive blueprint implementation won't have that, so you have the client either lagging and then being corrected forward, or being corrected backwards, because the sprint only begins when the server says it begins, and the server makes no attempt to smooth out the client experience
this video explains the problem with sprinting in BP pretty well https://www.youtube.com/watch?v=RtQRMcupJs0
Many of you have requested a way to leave me a tip so I've created a PayPal and a Patreon.
PayPal: https://paypal.me/reidschannel?locale.x=en_US Patreon: https://www.patreon.com/reidschannel
Discord: https://discord.gg/PdvudWx
You asked for it so here it is! This is my Networked Character Movement Tutorial complete with a full download to the pr...
Hey guys, I have the following problem: when i do a line trace on the client then the impact point does not match with that of the server. Any Idea why that is?
so, your options are to either roll up a system to predict sprinting client-side and apply those predictions server-side
which could technically be done in blueprints
or you use C++ and integrate those changes with the CMC, which already does those things. Although I've never actually implemented this kind of behaviour in the CMC myself, so I don't know how hard it is, but I'd imagine it's easier than building an extra system on top using blueprints
so could i have the server lerp the clients speed changes to prevent jitter
I think so.
It's possible that the CMC needs messing with regardless to prevent it from sending bad corrections
but you basically just need code on the server to recognize that, after receiving the client's updated sprint status, it has to look back and figure out where the client should be, according to when they hit the button
my idea is the clients speed lerps between the changes while the server just applies the speed change so maybe the time it takes to lerp to the sprint speed will compensate for some lag
Do you have any more details about the trace? If you're tracing from/to moving objects, then the impact point would be unlikely to be exactly the same between the client and the server
At the moment the server is standing and the client shoots him. It works most of the time but seems inconsistent.
It might smooth out the experience for some or most players, but it's effectively applying a fixed client-side offset to account for lag, which basically means that the experience will go from being "ideal" at 0ms, to being ideal at some other latency; anyone above or below that will still see some correction jitters, and the behaviour will vary depending on whether they're faster or slower than that
How different are the results between the client and server? And, are you using the control rotation to determine the trace?
I dont know how i did it but the impact points are now almost synced. it is maybe 0.1 or so off.
i did find a plugin to solve some of this but to also have it work in ue 5.0.0 ill probably need to recompile it
I was using the C++ function PlayerController->GetPlayerViewPoint with out_Location and out_Rotation. I made a custom BPL to expose it.
And i am using 2 traces. First from the player view point forward and then use that impact point as the end location of the second trace.
Works fine for me now
But thanks anyways
If you're using the control rotation, I think that control rotation is "low resolution" over the network; to save on bandwidth, only an approximation of the player's control rotation is sent over the network
so you'd get slightly different results by default
I don't have total confidence in that though, it's just something I bumped into while writing some simple networked FPS code
and it was a while ago
In order to send a structure over to the server, Serialization to json is the best way to compress the file? I'm trying to reduce the volume of the data
what about binary?
honestly I don't know π works better?
If you want to save it to a file a binary is usually lighter
but no human being can read it xd just machines
Unreal has FMemoryWriter FMemoryReader and IFileHelper to help you
I have to send struct of position and retrieve when next game starts
i think there is no other reason than legibility to use json instead of binary imo
great, I didn't knew it!
thanks a lot dude, do you know where can I find more about this?
Digging the engine:
FMemoryWriter
FMemoryReader
IFileHelper
Google them also as binary unreal compression or somthing like that
thanks dudeπ really appreciate
Unreal has access to a few different compression libraries. They seem partial to zlib
what service would you recommend for a MP indie game just starting to go online?, so far I've heard amazon works ok.
I'm at the prototype phase, so it would be shared with a couple of friend for now.
take a look at playfab too
interesting, seems to be free to start
i've worked with aws on amazon and its ok if you are building a medium size indie project, for smaller project maybe its a little bit expensive
I was under the impression that it was free
or you mean after reaching a certain threshold of users/data?
i think i remember that any long-term server running in aws cost money
for now I only care about being able to test and prototype it with a limited number of users
until 100k users playfab should be free
without much hazle
I mean, if you leave the game in development mode and don't go live it's actually free
yeah, that's what it seems
I am using it and not paying so...give it a try
I wonder if there is like, a way to learn what steps should I take when transitioning from closed prototype to full online
in terms of, marketing, visibility, etc.
maybe there are companies that specialize in this, no idea.
can't tell, maybe make sure the game works and then you see π