#multiplayer
1 messages ยท Page 649 of 1
but if you're just testing with a handful of friends, just host the server on your own machine.
use EOS!! ๐
you can use hamachi too
hahahahha
EOS cannot host dedicated servers themselves, it's just a vehicle
yeah I know nitrado/aws is your friend
having worked with AWS Gamelift and EC2 scaled in a released game, go with PlayFAB
Totally true!
AWS Free Tier includes 750 hours of Linux and Windows t2.micro instances, each month for one year.
To stay within the Free Tier, use only EC2 Micro instances.
What's the Properยฎ way to pass data to server on join? I have a struct representing the joining players character and loadout. What's the best event to hook into so the server can spawn the dude for me correctly?
Using Stock Steam sessions
that depends on how that data is being retrieved. Trust the client with nothing. The server should be fetching the clients loadout/character once they have joined the server and pass that to them.
Once you've joined, send the data via RPC
Server validates it, then applies
In our case we think of it more as a request than a demand
That's my current approach, thanks for validating. I suppose later I'll have to make sure the client doesn't hack in some godmode character but it works for now.
Its a coop roguelike so I'd like to at least make it slightly difficult to scum
What conditions cause a remote function call to not be executed when reliable execution is turned off? Is it only packet loss? I have a function I'm calling that is failing to be called 95% of the time, even when I'm running with clients locally and network emulation turned off.
Could be that there just isn't enough room left to send it, might be the case if you already have a lot of properties or RPC's
If they don't fit into the unreliable buffer that network frame, they get dropped
also i would up the max rpcs
by default engine sets it super low
[SystemSettings] net.MaxRPCPerNetUpdate=5 by default its 2
iirc fortnite sets it to 10
Hey, i'm having a FCharacterDefaultStats struct as property which contains stuff like; CurrentHealth, MaxHealth, HealthRegRate(Same for stamina and mana), but it also contains the IsDeath state.
Does it make sense to separate the IsDeath boolean out of this struct when i want to have an OnRep method for the IsDeath changes ?
I kinda think if i'd let it stay how it is atm i'd increase the send packages by a lot since the OnRep would be also called for each single taken stamina when sprinting e.g.
Maybe my concern doesn't even make sense here since i still don't really understand this whole system.
Also while reading it, is there any down side to just increase it heavily ? ๐
Well rpcs cost game time on the server
Huh, okay. Is there a way to debug whether it's being dropped via that route?
I'll look at that setting too. That does sound very low.
I see, would setting it from 2 to 5 be a good balance, or does it still heavily depends on the kind of game ?
https://answers.unrealengine.com/questions/53219/network-how-to-debugshow-network-traffic-in-ue4.html This is very useful and didn't require any complicated build steps (FYI for anyone searching in discord that may come across this)
I don't see MaxRPCPerNetUpdate in my ini file and I don't see anywhere on the net really mentioning it within the context of unreal engine
You need to add it and the best documentation is the source files :)
Yeah, setting it from my console to a high value (like 10) directly doesn't seem to fix the issue. I do see the stat of "saturated connections" going up when I have too many clients, but oddly enough, it doesn't seem to correlate with the issue arising. I seem to have the issue when the connections are saturated as well as when they aren't.
Looks like it's supposed to log if we go over that limit: https://github.com/EpicGames/UnrealEngine/blob/c3caf7b6bf12ae4c8e09b606f10a09776b4d1f38/Engine/Source/Runtime/Engine/Private/DataReplication.cpp#L1880-L1881 So I just need to figure out how to enable that logging
Yeah I don't see that line being logged. Hrm.
Man, nothing at all about that RPC even with full global verbose logging turned on. Also, I tried disabling a fairly frequent multicast I'm firing that would be sending far more frequently than the RPC I'm calling. The RPC still is being dropped for some reason.
Something more subtle is going on. If I call the RPC from a keypress it works fine. Blah. This makes no sense!
The only thing that seems to differ is where I'm kicking off the function call that ends up calling the RPC. When it's unreliable, it's from my projectile. When it's reliable, it's on my player. Even if I put it in a function on my player though and have the projectile call that, that doesn't seem to fix it.
Maybe because my projectile has a lower net priority? Would that cause the RPCs to be dropped even though they're being called for a high-priority actor? Edit: Raising the priority to be the same as the player didn't do anything.
Looks like upgrading to 4.26.3 fixed it.
Thank you for coming to my TED talk
is there any way to convey a vector of a players camera if the camera is an actor that only exists clientside
im working on a beam / laser type of feature and it works just fine clientside since it follows the camera or where the character looks but other clients wont see the change
I also have some camera-angle-dependent features and I'm not using an actual camera actor, so I have a replicated UPROPERTY which holds the camera angle, and I update this via RPC from CalcCamera. Not sure if this is the best way or not, though.
I have to replicate the actual direction the player controller is looking too for animation purposes. I think I do an unreliable multicast to do it.
does onrep get called for all clients ? or just the owning clients ? if so, how can i have onrep triggered for all clients ?
it depends on what the onrep is being called on
if you have an OnRep on say a player controller, only the owning client and the server will get that update
but if you have an OnRep on the playerstate, each client has a copy of the playerstate, so they'll all get the update
What about ActorComponent
And from what you're saying, its only achievable if its moved into the PlayerState ?
nono
the player state was just an example
each client has a local copy of other client's player state
for replication purposes
If you're spawning the actor in the world from the server, then all clients will have that actor with it's components
assuming the component replicates as well
so an OnRep would update them all at once
But would the OnRep function be called on every client
lets say i want to display a ui on top of the player
depending on the health of the player
seen by all players
the health is a replicated variable
so i shouldn't put the displaying of the ui inside the onrep ?
no
UI is strictly client side only, well it should be
if you want to use health, you can either store that in a component, the player state, or a gameplay ability tag (if using the Gameplay Ability System)
The server should control the damage/healing the health receives on that actor
if you're using a function like SetHealth(float inHealth);
it would look loosely like this:
YourActorComponent::SetHealth(float inHealth)
{
Health = inHealth;
OnRep_Health();
// OPTIONAL HERE
ForceNetUpdate();
}```
you can use ForceNetUpdate() to force a variable to replicate so clients have the most up to date info about that
I assume thats a server rpc
sorry
YourActorComponent::SetHealth(float inHealth)
{
if (!GetOwner()->HasAuthority())
{
SetHealth_Server(inHealth);
return;
}
Health = inHealth;
OnRep_Health();
// OPTIONAL HERE
ForceNetUpdate();
}
YourActorComponent::SetHealth_Server(float inHealth)
{
SetHealth();
}
something like that ?
no need to use an RPC
YourActorComponent::SetHealth(float inHealth)
{
if (!GetOwner()->HasAuthority())
{
SetHealth_Server(inHealth);
return;
}
Health = inHealth;
OnRep_Health();
// OPTIONAL HERE
ForceNetUpdate();
}
YourActorComponent::SetHealth_Server(float inHealth)
{
SetHealth();
}
void OnRep_Health()
{
// Do UI stuff here
}
you can check role actually
1s let me double check some code I have
because I have that exact scenario I believe
thanks
so technically
you don't even need to do UI stuff there at all
you can just directly hook into the your health variable
or broadcast a delegate
how so ?
in the OnRep
and will it be visible to all clients
yes, OnRep causes the variable to be updated on all instances of that variable.
i dont particularly understand the part where you said broadcast a delegate
server side or client side
i assume client side inside the on_rep
just do it inside the on_rep
but you don't need to broadcast the delegate at all
if you're talking about health changing
there's no need
and the example I have, is for a server call unfortauntely
so wouldn't work here
Show code please.
Can anyone explain these network settings? My goal is to have my server allow 1mbps per connection with each connected client for a total of 15mbps (15 clients). What values would I need to set these at?
Hi guys! So I was following this tutorial by Dev Addict: https://youtu.be/EDNF2DNLhPc , and I ran into a couple of issues. At the first test, right after setting up the "Join" button, it doesn't work. I mean, I create a session, then launch another instance of the game, click Join... And nothing happens. After some debugging, I found out that it does not find any sessions at the Find Advanced Sessions node. Any ideas as to how I can fix it? Thanks.
Check out my Unreal Engine 4 courses:
โบSouls-Like Action RPG with Multiplayer: https://devaddict.teachable.com/p/souls-like-action-rpg-game-with-multiplayer
โบMultiplayer First Person Shooter with Dedicated Servers: https://devaddict.teachable.com/p/multiplayer-fps-inspired-by-cs-go
โบMultiplayer Top-Down Dungeon...
Are you testing in pie?@pure elm
Steam only works in standalone
And you need 2 pcs and 2 steam accounts.
It's annoying.
Yeah I've been testing in standalone
And at the first test I haven't got steam setup yet
Just UE and Advanced Sessions
Ah ok. So you're just testing with the null system?
Yep
You're sure the session is bring created?
Yes
I've not worked with the advanced sessions stuff in a good long while unfortunately.
Is your project c++?
Oh
But I would check to make sure your session is being advertised.
And that it's joinable in progress.
That should sort out the find session issue
Np. Feel free to ask follow up questions in here later. Others will help.
Anybody know of any guides or tutorials on how to set up sending/receiving json files over a network between two separate UE projects/games? (Using a client game and a separate server game project for security)
@fading birch I just noticed something
// Use newer RPCs and RPC parameter serialization that allow variable length data without changing engine APIs.
static int32 NetUsePackedMovementRPCs = 1;
FAutoConsoleVariableRef CVarNetUsePackedMovementRPCs(
TEXT("p.NetUsePackedMovementRPCs"),
NetUsePackedMovementRPCs,
TEXT("Whether to use newer movement RPC parameter packed serialization. If disabled, old deprecated movement RPCs will be used instead.\n")
TEXT("0: Disable, 1: Enable"),
ECVF_Default);
That's in the CMC
There is a "packed" version of the Server Move RPC
That sends a struct that can be extended
Which allows doing what I asked about in a nice and clean way, without having to adjust the API
And apparently that is on by default
That would also allow for passing over way more flags
You have two projects for the same game just to create Server and Client builds "secure"?
You can literally tell UE4 to strip Server data from Client builds :<
But okay, whatever you want to do there would be done via some simple socket logic
check how to listen for incoming stuff on a socket and how to send, that should give some tutorial results
Running into replication issues and wondering if anyone has experience with it to suggest a workaround
I have a "container" actor component that can contain items. Simple array of a struct, {name, amount} style. Defaults to an empty array. Component set to replicate and the array replicating with an OnRep callback.
So I make a level instance, drop in a chest actor, add the component and fill with item entries. Start a server and modify the inventory. Start a client and join and everything works as expected - OnRep callback triggered on the client and the client updates it's inventory to match the server. I debug print both inventories and client always matches server. Tested various things like this and all working great.
However, one thing is not working. If I start the server - inventory full of things from level instance load - and then empty the inventory completely, and then join a client, the Server doesn't tell the client that the inventory is empty and the client never triggers an OnRep. If I ask the server to print what's in the container, it's correct - empty. If I ask the client, it shows that the container on the client-side is incorrectly full of items from the level instance.
The only way I've managed to get this to work is if the server empties the container while the client is connected. eg. Start a server - inventory full of level instance load things - Start a client and join. Then empty the container. In that situation the client receives the replication, triggers OnRep and both inventories match.
That sounds an awful lot like an Engine bug
@slender rivet Can you try something for me
Does your Chest have the Component on it already in its Blueprint?
Or are you adding it afterwards onto it?
I've tried both. Having a blueprint with the component already in it, and having a generic replicating 'chest' actor that has no existing component
Wondering if it's an engine bug where the engine is mistakenly thinking 'That replicating variable has been set to constructor default. Don't sync' and ignoring the fact that the client will be using the level instance array.
It is
I mean
At least that's what I had and thati s reported and backlogged
An easier example is this:
- Blueprint with a RepNotify Boolean set to false
- Blueprint placed into World, where Boolean is changed to true on the Instance
- Server sets boolean to false before Client joins
- Client joins and has boolean still true
Something like that
It compares to the archetype, not sure why and also not every time. A delay fixes it but delays are of course shit
Sounds like it's a case of waiting for it to be fixed then and doing some horrible workaround for now
You can probably wait a long time
You can test if this is the case by adding the component to the class
And adding 1 entry to it
Thinking I could have inventory default to some kind of weird value like [{name: "Empty", amount: 0}]
Then placing it into the world
And then filling it
And if the clearing of the server then works, then it probably compared the empty vs the archetype that had one entry
Yeah that's what I meant basically with the gibberish above :D
๐ doh. I take it this bug will apply to anything that has a replicating property set back to constructor default
sry for late reply, i literally discovered the 'stripped down server build' after posting that, and started following a tutorial. I've been using UE through the epic launcher though, so I have to figure out how to convert my project to the github source build first, then I can move forward with the server/client magic ๐
thank you for the tips though! i'll start searching around tomorrow
You can do that in Launcher Builds too
The only restriction is that it requires c++ as far as I know
Not sure you can strip BP code
But simple wrapping your code in a server only macro should be enough
Probably, yes
Thanks. Hmm - is there a way to force a replication to occur?
Not sure, ForceNetUpdate didn't help iirc
What a weird, annoying bug.
Yeah it is :D
It didn't work when I tried from the launcher. Specifically I tried to build in VS using Development Server and received this error when building, which led me to reading I needed to use the github source UE:
perhaps I'm dealing with a completely separate issue
was wondering if anyone could help - i have this blueprint on an blueprint actor for on overlap - however when i overlap using the server player the rotation of the client player isnt being changed even though its fired when debugging
Uff, GetAllActors of Class two times? :D
when i go through using the client player it works as intended
yeah one for the player the other for where i want to teleport them to
Set the Players Control Rotation too
Maybe that resolves it already
Don#t really see wht's going on in your image. I would suggest you clean it up and send an easier to read one
Also 99% of the time, GetAllActorsOfClass is not required and just bad coding
If you need references to actors, there are usually other ways
https://blueprintue.com/blueprint/ss8rjapm/ this should be easier to read
There are multiple problems
The Overlap is called on all Players
That's for starters already something you need to take into account
It's not only running on the server or stuff like that
The first GetAllActorsOfClass is confusing. Don't you want to teleport the Overlapping Vehicle?
The other thing is
GetAllActorsOfclass does not guarantee you to be always in the same order
Index 0 is not always the same actor
Neither is Index 1 when you use it for RacePositions
You should have a manager that has the references and has them in order
Don't overuse this node
i want to teleport all vehicles
But you are only getting the first entry
If you want all, you'd need to loop over the array
Ah you use Index 0 and 1
right now im working with 2 vehicles and its working with both - it teleports just doesnt set the rotation for the client player
the teleport works fine
its teleporting to the right place and everything
just the rotation only sets on the client player when the client player goes through it themselves
if the server player goes through and triggers the overlap then the rotation of the client player isnt set
Right, okay, just keep in midn the code really should be improved.
Try setting the ControlRotation
Make sure that if you set the control rotation, that you check if the controller is valid before accessing it
Can someone refresh my mind on NetSerialize for a simple float?
Trying to look through examples, but most of them try to pack the float into a byte, which I don't need atm
it still doesnt work
Any errors when you stop playing?
both rotations are set correctly if the client player triggers it but when the server player triggers it the client player rotation isnt set
no errors
i've tried adding a delay also to see
and the delay is getting fired through
and the rotation just doesnt get changed
but the teleport still happens
Not sure atm, sorry. I only had issues with ControlRotation overriding the Actor rotation and stuff like that
Hey, i have already setup a dedicated server with a 6 player(3v3) gamemode.
Since we are using the open <ip-address>command to connect to the server using an ip address which is recieved from the matchmaking service, Is it possible to have multiple matches running on the same server?
is it possible to isolate the 7th player into another match in the same server?
since its not feasible to have a server for every single match is this a good way to have clients connect to the server or is there a better way to do the same?
you essentially just run multiple instances of the game server .exe on one box, and assign them to different ports
that's good to know, i'll have to set up a pool of ports on the server firewall for multiple instances then
but still ports too are limited right
like suppose a huge amount of people join
Everyone connected to the Server communicates on one port
E.g. you don't have 100 ports all assigned to each player
It's one port for all traffic
think of ports as the key to a door, you're basically just giving all your players a key to that one door (server) they are going to connect to...you can have multiple doors (servers) on different ports, so they have their own key for each ... if that makes any sense ๐
I think we will not came into the solution about above this question?
You mean the Ports stuff?
You can't run multiple matches on the same DedicatedServer.
You need to launch multiple DedicatedServers, one per Match.
These can run on one and the same physical (or cloud) server by using different ports.
That's basically the answer
@thin stratus
Pretty sure before you run into the limits of ports, you'll run into the limits of hardware
You'll need multiple physical (cloud) servers
One is not enough
Not even with unlimited ports
so is there any other way to connect to a headless server?
@thin stratus May be he can answer...
Yaa these is the solution for this.. @ancient bramble
My projectile still moves even when I don't put SetReplicatedMovement to true, only SetReplicates.
should that work that way?, apparently in the guide I'm following the guy says that if I don't set it to true, it wont move, but it does.
maybe a different engine version made it that way, no idea.
Depends. If you are "firing" the projectile on every player, it will move
The Replicated Movement is to sync the location and rotation from server to clients
a bit confused there
the action of firing makes it move and maybe rotate, so...
just following the Tom Looman guide, that's why I was curious.
I was expecting to see the projectile spawn in place and not moving.
It's probably moving independently on both ends
so in which case should I use replicateMovement?
To keep things in sync
I can tell the Projectile to move on the client and on the server.
And if I cross my fingers strong enough, they might fly the same direction and distance :D
Replicating Movement updates the location and rotation (smoothly) if needed.
At least on projectiles, normal actors aren't smoothed
There is also an Interpolated Component on the ProjectMoveComp which you can set
usually the mesh you want to move smoothly, while the root collision is instantly moved on correction
is Replicate Movement's implementation dependent on the movement component at all or does it internally do some sort of smoothing of the actor motion? Never really dug into how that works exactly.
ok I think the reason why it moves without setting that to true, might be because of how the projectile gets spawned?:
that's on constructor
The initial location rotation and velocity is always sent even if replicated movement is false
So if the server initialises the velocity, that's also the velocity the client will have when it receives the actor.
See UPackageMapClient::SerializeNewActor
Also shouldn't call SetReplicates in the contructor, just use bReplicates = true
does that make any difference?
Doesn't matter
That doesn't set the actors' velocity anywhere anyway, but the projectile movement component does
alright
I'm reading eXi guide about networking, didn't finish it yet, I guess at some point it will talk about what makes sense to replicate and what not.
Hi guys! So I was following this tutorial by Dev Addict: https://youtu.be/EDNF2DNLhPc , and I ran into a couple of issues. At the first test, right after setting up the "Join" button, it doesn't work. I mean, I create a session, then launch another instance of the game, click Join... And nothing happens. After some debugging, I found out that it does not find any sessions at the Find Advanced Sessions node. Any ideas as to how I can fix it? Thanks.
Check out my Unreal Engine 4 courses:
โบSouls-Like Action RPG with Multiplayer: https://devaddict.teachable.com/p/souls-like-action-rpg-game-with-multiplayer
โบMultiplayer First Person Shooter with Dedicated Servers: https://devaddict.teachable.com/p/multiplayer-fps-inspired-by-cs-go
โบMultiplayer Top-Down Dungeon...
@pure elm we need code.
Also tagging here won't work and is a good way to get banned.
See rule 2
Why instead of making a rule they didnt just disable it?
It is disabled, doesn't mean you should attempt to mass ping people. If someone has the time to help or by chance knows the answer they may help you out, but just trying to ping people isn't the solution. Same is said in the rules.
we also still need code or can't help you
@thin stratus proper channel this time, my bad
@fading birch OK, gonna repost tommorow, with samples of code
@pure elm you need to run the game on two seperate PC's
else steam will never find any sessions
@meager spade i was helping them last night. #multiplayer message
they're not using steam yet, just null
ioh
so still fighting my issue here ๐
think its related to updating session settings
nope, i have the most simple of setups and sometimes it works, sometime is does not
is there like a rule of thumb on what should happen on the server and what on the client?
If it has to be canonical that "That Happenedยฉ", do it on the server. Try to think of your game in terms of the most stripped down data that represents the game. If you're familiar with MVC, the Model has to live on the server, the view is what you see on your screen, and Controller can be your interface between them.
optimisation question: if im doing a laser beam spell thats basically an actor that ticks every frame in order to update its location and rotation, would it be better to have a collision component that updates its size / length every frame or use a box / line trace every frame?
So for a super basic shooter, I'm the servers eyes, everyone is just a bunch of capsules sliding around and line tracing at each other. The sever doesn't care about particles or sound or other polish, it just cares about the actual game model itself.
the box trace or collision component would be used to damage viable actors
@shadow hatch depends on if it's meant to have thickness or not. Either is fine. Traces are dummy cheap
oh what do you mean by thickness? like the size of the trace box?
oh nah it should be relatively small
well im modding for a game where aiming is not easy, youre mostly stuck in third person with over the shoulder camera plus the beam is not laser-thin
a line trace would probably be too frustrating
Ya a box trace should be good
thank you
anyone knows if there is a way to get like a networking diagram of sorts?
to know what gets replicated and where
Does anyone know if Chaos vehicle have client side prediction instead of waiting for server round trip like Apex vehicle?
im pretty sure they dont out of the box
as Epic has said they don't do prediction on vehicles im pretty sure
Ok thxs Em,
Yea I have a feeling so
Have clients predict behavior of client owned actors based on player inputs; simulate this behavior before receiving confirmation from the server (and correcting if necessary). We use this model for Pawn movement and Weapon handling, but not for Vehicles, as the complexity of saving and replaying the physics simulation outweighs the benefit of reduced latency for vehicles handling, where typical internet response latencies arenโt that different from typical real world vehicle control response latencies.
Networking compendium pinned in this channel
I'm reading it, probably didn't reach that part yet.
There's a big Venn diagram towards the front of it that shows which objects exist where
I am almost certain Forza Horizon or the Crew2 uses prediction.
Did any game shipped with UE vehicle without prediction?
I highly doubt that any big name game has ever shipped with the Unreal Engine stock vehicle system. It's pretty crap to be honest, if you're trying to make a vehicle driven game, roll your own.
Goal
if you were to make an RTS-ish game, the units (let say ships) would be vehicles or normal pawns?
Also if you figure out a nice way to do a very rigidly coupled drivetrain and tire model, hit me up
Normal pawns unless you need something very simulatoresque
Usually RTS games have very simple individual unit mechanics
great.
probably explained somewhere, or obvious.
When you call UFUNCTION(Server, etc), you are telling the server to run a RPC, then comeback to the client, and execute whatever you have in your function.
when you call UFUNCTION(Client...) what does it do?
Server means to run the function only on the server
Client means to run the function on the owning client
NetMulticast means to run the function on the server, then to all clients.
right, but what is the difference between just plain UFUNCION() and UFUNTION(Client...)
don't functions by default run it only on client?
I have that feeling that I'm missing something critical to understand how it works ๐
The 2nd one you call on server and it runs on client. Server -> Client communication
ok, in the example I have the teacher uses ServerFire, that I call it on Fire() in my client code, which then runs on ServerFier_Implementation()
so it's the server RPC'ing the client, I assume.
seems like Server and Client do the same thing, at least for my example
Hi, I could need some help replicating my current Enum value. Enum used as Transition Rules between different AnimBP States.
Character.h:
//AnimBP States.
UENUM(BlueprintType)
enum class EPawnStance : uint8
{
Stand UMETA(DisplayName = "Stand"),
Crouch UMETA(DisplayName = "Crouch"),
Prone UMETA(DisplayName = "Prone")
};
AnimInstance:
// Animation Stance States
bIsStanding = PlayerCharacter->CurrentPawnStance == EPawnStance::Stand;
bIsCrouching = PlayerCharacter->CurrentPawnStance == EPawnStance::Crouch;
bIsProning = PlayerCharacter->CurrentPawnStance == EPawnStance::Prone;
I tried this, but it's obviously wrong ๐
//The current stance of the player character
UPROPERTY(VisibleAnywhere, ReplicatedUsing = OnRep_PawnStance)
EPawnStance CurrentPawnStance;
UFUNCTION()
void OnRep_PawnStance(EPawnStance NewStance);
void AShooterProjectCharacter::OnRep_PawnStance(EPawnStance NewStance)
{
CurrentPawnStance = NewStance;
}
Is there anyone who can be so kind and explain to me? ๐
Hey yall so currently I have this bug in my game where clients can't move from the game to the main menu. I have a simple check for if one player has 3 kills, then an event will be run on the server to destroy the session. All that happens is the server moves to the menu but the clients just reload the level(offline, of course).
I'm using blueprints btw
Any ideas what's going on here?
This goes over the general elements
https://www.ue4community.wiki/legacy/network-replication-using-replicatedusing/repnotify-vars-2bl75t21
How is the server travelling back to origin? Are the clients travelling with the server?
Here is my setup. I believe they're traveling with the server but correct me if I'm wrong.
No, they're not
OpenLevel disconnects everyone
hence the behavior that you're experiencing
Check the docs on Steamless Travel/server/client travel.
Alright thanks! will do
@hollow eagle sorry for the tag, moving from #cpp
"Then I guess I have a different question: Do you happen to know when do Player states get their names assigned? I'm getting (on the server) PlayerName == "" for connected clients when running from MyPlayerState::BeginPlay"
If I run the function that updates things (it's a replicated struct, where I'm doing) cpp SetBaseInformationFromPlayerState(APlayerState* InPlayerState) { if (IsValid(InPlayerState)) { PlayerID = InPlayerState->GetPlayerName(); } }
and then running from BeginPlay if Authority cpp PlayerStateStruct.SetBaseInformationFromPlayerState(this);
the server gets a populated name, but the clients get an empty string
That I don't know.
I see. Thanks for answering though ๐
Any way I could make login via Web3?
Can we set events as virtual ? So it can be overrided
You can. Only for BlueprintNativeEvents
also #cpp
Well i meant RPC, my bad.
RPC call a function and this function is virtual ?
for example:
UFUNCTION(Client, Reliable)
void Foo();
virtual void Foo_Implementation();```
It's ok to limit player input to avoid spamming a button that calls a RPC(like to once every 0.1s) or it's going to make players experience worse?
HI! I wonde rhow can i set more than one postprocess effect for one Player. At the moment i can bind only one to the camera or use them as unbound, but unbount creates wrong postprocess effects
Normally an input wouldn't directly call an RPC, you would "gather" the input during the frame, then send it to the server in batches.
Then whatever processes that input determines at what rate it should be sent
Hello, if i make a call to a delegate from the client, will the server react to it? for example. i got delegate OnPCSetUpFinished, i trigger it when the client finished it's initialisation. So will the server react to it or i should make RPC like Server_InitFinised and trigger a delegate there?
This is the call on client side. So server wont hear it right?)
Like Lorash said, only RPCs will talk to another machine. Delegates will only run on the machine they're bound in. ReplicatedProperties and RPCs are the only two things that will function across network.
RPC it is) got it. Thx
Im running a dedicated server but I am wanting to spawn stuff in by passing a command to the server externally is this possible?
Basically RCON stuff?
Pretty sure that's somehow possible, but not without some extra code?
Maybe UT has something for that
Hey! Is there an in-built method of checking if a replication notification is the initial one?
In C++
I guess the quick and dirty way would be a flag that I set to true after the first rep notify, but I was wondering if there was a cleaner way
there is a PostNetInit functiont hat runs after first round of replication(callbacks) @solar stirrup
Awesome, I'll use that to check. Thanks!
use that to do whatever you want done only during initial replication round
then you don't need to check anything
I recently upgrade a project from 4.25 -> 4.26 and i'm noticing that my dedicated server is calling PostLogin on it's own, with 0 players connected to it.
that doesn't seem like it should be happening at all
When I open 2 windows in editor (number of players > 1), collision for some objects (trace hit under cursor) stops working for both windows. There is no replication and these objects are created locally for each window, and net mode is Play Offline. How is that possible?
anybody can help me ?
Heyo can session names be set in blueprints or is that still a c++ only thing? (I don't plan to use the advanced session plugin)
theres an internal rpc limit per Nettick(?) and of course there is the per player bandwidth limit.
so if its an expensive rpc, then you need to limit it so the player doesn't use up all of their bandwidth.
keep the player experience good and just mark the rpc as unreliable if the rpc is small.
and rpc on tick is a big no no no matter how you dress it.
a player spamming an input for rpc is ok.
now if your rpc is spawning actors or doing expensive work on the server well... might want to have a limiter on that ๐
Ty @half jewel
the default BP stuff for sessions just uses the engine default name for sessions. There's also some issues with it where it doesn't handle silently failing.
so C++ is the only way unless you use the Advanced Sessions plugin
I'm using Advanced Sessions plugin for creating dedicated server session but I'm unable to display my server in Internet Tab under Servers in Steam. It's visible under LAN and works on local network but I'm unable to connect between different networks.
Is it even possible to make this with this plugin or I need to fix code for that or maybe there is plugin I can buy that actually works? ๐ญ
how are you testing it?
2 pcs 2 steam accounts?
in stand alone mode?
does the steam UI popup when you launch the game?
what would be difference between marking something as "Client" on the RPC and using ReplicatedUsing to execute functions only on clients
seems similar, not sure when should I use one or the other, and why both exist
Reminder: Session and OnlineSubsystem related questions belong into #online-subsystems.
Please redirect users whenever you can. Cheers! 
You are asking when to use an RPC vs a RepNotify function.
RPC will only be executed for whoever is relevant at that time. So not for hotjoiners or peeps that are far away.
So if you want to update a state of your actor this is less ideal
A RepNotify function gets executed when the client receives the replicated variable. That can be minutes after you set the variable, ensuring they get the change and call the function.
(In BPs the Server also calls the OnRep function cause BPs are janky)
An example would be a barrel that explodes.
The explosion sound and vfx are only interesting for whoever is relevant at the time of explosion. I don't need the explosion effects when i join 30 minutes later. So this can be an RPC.
However the change from intact to broken barrel mesh is a change of state. I want to see the broken barrel when i join 30 min later. So this should be an OnRep (e.g. A boolean called bExploded)
So you mean they selected a class beforehand?
Generally the GameMode class has the functions you want to override
E.g. SpawnDefaultPawnForPlayer or something along that line of wording
I see, I guess there are a few concepts I still need to wrap my head around to fully understand how to develop properly. Thanks.
@thin stratus Thanks i found that .
Do you know what the GameMode centric way to do this would be?
- Start up game. You have no default pawn. PlayerController sets view target to a static camera and plays a little intro camera action.
- Pawn parameters are selected or you resume a saved game, either way, we now have info to spawn your pawn.
- ? Spawn pawn somehow? Could just spawn actor and possess but that feels hacky.
I'm thinking something like restart player might be the ticket , do I override Choose Pawn Class for Player to use the info from character creation / resuming game?
For 1. I would use the PlayerCameraManager in combination with the GameState to get some self-registering camera actor or similar.
2. Here I would make sure the info is set on the PlayerController and then call RestartPlayer for 3. While overriding the GetDefaultPawnForPlayer function where you get the playercontroller to grab the previously saved info from, which will then make sure another restart will respawn with the same info.

Following this guide, and the guy says all the time: "because this code runs only on the server", but I have no idea why, or how he knows that.
any tips on how to know that ๐
Depends on where he is coding
If he's in the GameMode then it's because the GameMode only exists on thr Server
You should read my compendium that's pinned to this channel
@thin stratus Sir I didn't know you wrote that compendium . that mini book was amazing and really helped me to understand UE4 network system . ๐
should make his name bigger and emmisive fonts.
I recently upgraded a project from 4.25 -> 4.26 and i'm noticing that my dedicated server is calling PostLogin on it's own, with 0 players connected to it.
that doesn't seem like it should be happening at all
Breakpoint it and follow the callstack upwards
that was my plan later on, was just curious if something changed
now it's not happening at all ????
Packaged build. 2 pcs, 2 steam accounts, 2 networks. Not sure about UI but I think it works.
moving this to #online-subsystems
i have a question does multi usher work properly or is it difficult to get it to work cause I am really new to unreal and i have been trying to find ways to work with a friend of mine on unreal engine 4
@dense orchid can you clarify what you mean.
My question was how can I collaborate with someone in unreal engine and share stuff with
The tutorial videos I find don't really help me out much or confuses me
@meager spade : sorry to bother, but I see you have experience with RestartPlayerAtPlayerStart.
In my gamemode, I call RestartPlayer() but my player doesn't get reset to the starting position. He just stays where he is.
I don't override any of the RestartPlayer or RestartPlayerAtPlayerStart.
Just wonder if you run into this problem.
@dense orchid version control mainly. If you're both going to be working on the game, as in through UE4, you'll need to use version control. If they're just going to be a tester, then you'll need to send them the packaged binary of your game. You can also purchase a steam app id ($100, 30 day turn around) and upload it to steam for testing purposes. You'll just give them a steam key, which you'll request through steam works and that's that.
Alternatively, since you're already using version control, you can just give them access to that, or a facet of it and put your packaged game there
Is there any in-depth tutorial videos for version control @fading birch
Ok thank You @fading birch
Anyone know how I might replicate the same property with different values per client?
I was going to just duplicate the actor for each connected client but that's a bit heavy handed
The use case is time dependent property values where each client can specify their own time
you would likely want a struct
with say PlayerState and Time in it
put this in a replicated array
or i think you can use the FUniqueNetId
tho personally playerstate would be easier, tho i am not sure why you just don't have this "time" value on the playerstate
as there is a unique one per player..
@heavy marlin
Alright thankyou
It's multiple values that are time dependent btw
And yeah it would make sense to put it in PlayerState or PlayerController, and maybe as a map keyed by actor id or some thing that ties it back
And use ffastarrayserializer
I have a (I think) pretty stupid question: Is it possible to run a game as a client without connecting to any server?
The Game does not count as Client without being connected to a Server
(I'm not even sure if my initial question makes sense, I'm slightly lost atm still)
You have 4 things you can be as a Game
Standalone -> Basically Singleplayer, nothing networked
DedicatedServer -> Headless Server that has no rendered version of the game
ListenServer -> A Player that hosts and acts as Server while also being able to play
Client -> A Player that connects to either a Listen or Dedicated Server
Okay, and I assume there isn't any straightforward or easy way to "fake" being a client, without actually connecting to an existing server? (aka executing all logic etc as if it were a client, while no server really exist).
I don't think so.
The only reason I would see is if you want to do some unit testing
A client is more like a window to the whole thing. Or that's how I think of it.
Well we are not talking about a Game Client aka the Game itself.
My use case is a bit convoluted, I'm using nDisplay's clustered rendering and am trying to fake the nodes as clients somehow, while only the master node is a real client
it kind of works if the master is the server too, and the nodes run as standalone - that way they execute the same-ish logic
And that is limited to 4 players by default and I doubt it can be applied here
Yeah a ListenServer and Standalone are sort of the same
Just that the ListenServer accepts connections
And probably does some magic under the hood
exactly, so what works for me atm is that I run the master as listen server, and the clients as standalone
those still aren't clients
then I manually forward events that arrive on the master via nDisplay sync to the "clients"
yep
Then why not start them all as Standalone
And do the communication with sockets
There are probably some Plugins that allow easier creation and communication via Sockets
We used that in the past to communicate between UE4 and non-UE4 application
Like Scalemodels
Or UE4 PC Project and slimmed down UE4 Tabled Project
Hmmm that could work, but would require a lot of custom stuff
which I probably can't get around anyway
I'm not an nDisplay knowing person, so maybe there is an easy solution
so basically nDisplay starts an instance of unreal on all nodes and on the master, and syncs those via sockets (render barriers etc)
I just asked my co-worker
The project she worked on in the past has them just as standalone
And nDisplay sends the events to communicate
That's "all"
Yep
So what I'm trying to do now is connect that to a regular multiplayer "server"
so basically have a listen or dedicated server running somewhere else
then connect the nDisplay cluster "master" to said server
but then the nDisplay master is in client mode, and the nDisplay nodes are in standalone mode
which makes syncing a nightmare
Why do you need the extra layer though
Why can't the master node do what your extra server is supposed to do
There is probably a reason, but for me it sounds more like overcomplicating it
Why does this make it a nightmare? Does nDisplay assume something about unreal's networking or is there another issue?
Yeah that would be one option, but then when you'd have two clusters and a few regular Unreal instances this becomes a bit of an issue I think
I don't see why running other nodes as standalone would cause problems if they get events from the master/client anyway
Is it that you're using HasAuthority checks? You can work around that by checking the net mode yourself.
Or add something to a config that you use to bypass authority checks
yeah it's basically that I want to be as less intrusive into the respective projects as possible
I don't think you're going to be able to achieve that, faking being a client sounds worse than just writing a new HasAuthority function
I would say it's not even possible to fake that
Yeah it seems to be that way, that was kind of expected ๐
Too much underlying stuff going on
Thanks a lot tho, figured I'd ask here before I try ๐
My Unreal multiplayer experience is unfortunately not that great yet so as always with unreal there's so much stuff that's possible somehow if you just know about it
yeah
Also, in case you want to know what we helped on which should be using nDisplay:
https://vimeo.com/572749947
oh wow this is really cool
Not sure what exactly my co-worker did on it, think some of the iPad stuff
And nervously sweating whenever the presenter touched the iPad
Yeah it bit further into the video you can see the actual project on the wall screens, where the location is reflected into the table
oh my god setting that up sounds like an absolute nightmare
Haha, probably
Hello again) What Actor do you use to handle replication for UWorldSubsystem. It is a UObject so there must be someone in the wold to handle replication of it's fields.
Just spawn an actor and use it as a proxy
But should it be replicated as well?
I'm not doing replication work in that Subsystem
Would also not make any sense for the problem this was solving
The GameState replicates and tells the WOrldSubsystem on BeginPlay that it's available
There is no need for additional replication
Oh god i got it. I did everything wrong XD I broadcast delegate OnRep_Notify but i should just make a setter and broadcast it there)
Thank you)
hi, i haven't touched ue in a few years now, i've been looking into it recently but i got a lot of confused information on the state of multiplayer in ue: some people say origin point shifting now somehow supports multiplayer? and ue5 is doing away with that and should support 'very large worlds'? any of that holds any truth?
Well, supported and usable are two different things when it comes to origin shifting. It does work, but it only really solves visual issues on the client. You can't move the Servers' origin. UE5 apparently supports double-precision worlds, but I don't know if that's complete yet and it also means double the cost.
thanks for the clarification!
we already said that it s not a good idea to make a multiplayer game now ^^
and we already answer for this issu
and, in french.....
It's not a good idea to make anything serious in UE5 right now. Epic say it's not production ready.
I wouldn't put any energy in doing so. You'll have an even harder time if users use it and don't encounter issues
just out of curiosity and i ain't sure if this is offtopic - are there decent books on game multiplayer that cover more than the bare basics? it's the one part of game development that i don't think anyone can just "wing it"
Anyone know the best way to detect on a client when a pawn gets unpossessed?
And yet "winging it" is exactly what im doing. Feels like a ticking timebomb at this point, but at least I'll learn what not to do!
Does it make any sense to have replicated variables in a UUserWidget ?
Same as RPC's.
I think it's a no, but since you can still override the GetLifetimeReplicatedProps method inside of the UUserWidget i'm not sure anymore
Alright, so it's just a thing you shouldn't use, or ?
Will note that for the future ๐
I am having quite some hard time spawning stuff in multiplayer. I don't know whether to make them happen only on the server and then replicate down to the clients or spawning in them all instances. I am currently spawning a gun on the start of my game and I am not sure how to handle it. Any advice?
If it's a gun, should almost certainly be spawned on the Server then replicated.
Spawning in Multiplayer is almost always server-side
For anything that affects collision or has some general gameplay behaviour
I am spawning on it on my character class. So I should just if(HasAuthority()) { SpawnTheGun }?
should I spawn it in another class maybe?
Seems fine
When executing some functions I have on the gun I it saying the gun has no owning connection. I am setting it's owner to be the character but doesn't seem to work. I do it like this: ```void AUnrealMultiplayerCharacter::SpawnGun()
{
if(StartingGunClass && HasAuthority())
{
UKismetSystemLibrary::PrintString(GetWorld(), "TEST", true);
CurrentGun = GetWorld()->SpawnActor<AGunBase>(StartingGunClass, GetActorLocation(), GetActorRotation());
if(CurrentGun)
{
CurrentGun->AttachToComponent(Mesh1P, FAttachmentTransformRules::SnapToTargetIncludingScale,
"WeaponPoint");
CurrentGun->SetOwner(this);
CurrentGun->GunMesh->SetOnlyOwnerSee(true);
if(TP_GunMesh)
{
TP_GunMesh->SetSkeletalMesh(CurrentGun->GunMesh->SkeletalMesh);
}
}
}
}```
The character would need to be possessed and therefore "owned" by the player controller too
I do it on begin play. I it throws the warning only on the client. Maybe when I am spawning the gun the controller hasn't possesed the character?
Yeah that's certainly possible
Tried setting on tick but no luck (just for testing) LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_TraceAssaultRifle_C_1. Function Server_EndFire will not be processed.
Still getting this warning
is it OK to think of the GameState as a way to communicate GameMode things to clients?
I'm kinda afraid of the use of Multicast RPC's, but i think in my case i should use it. But i wanna go safe and ask first.
My use/case would be basically just to spawn some death particles, that's totally a case for Multicast's, or ?
The fact that something died should already be replicated. Use that to trigger everything that happens when it dies.
Like you don't need the multicast play a sound and then multicast play particles and then destroy actor and then multicast some other thing, just have a sort of death state that something goes into or a multicast death RPC and locally trigger all the visuals and other decorations
The actual died part would be handled differently since i have to destroy the mesh and all, but the particle spawn seems to be a multicast case since it's okay(and also wanted) if it doesn't get fired for clients which aren't relevant
Why not just spawn the particles when you destroy the mesh
I guess that should also work, kinda thought i'd have to use an OnRep for this, but i think that's something i shouldn't do, or ?
As in OnRep will call the destroy mesh and such
I prefer death being in on rep of some sort of variable, probably an enum or a boolean
But if i'd use the OnRep to also spawn the particles it might get called 10 minutes later once you are relevant for it. That seems kinda wrong to me
hey guys, im trying to figure out the best way to do fast-firing abilities, like automatic weapons or channeled spells that tick multiple times a second. Currently I have things setup to just multicast every tick of an ability (or every shot from a weapon), but this comes with 2 downsides. 1. is that im multicasting a LOT. 2. is that i dont have a way to skip the owner when multicasting, and while i can filter the event by NetRole (if Autonomous Proxy, don't play the effects), its still sending the message in the first place when the owner has already done prediction for effects in most cases.
I was considering trying to set up some kind of on-rep variable for any given cast that updates every tick or an ability (I believe this is similar to how ShooterGame does its burst counter?), that can just trigger the effects in the onrep, and skip owner on the replication condition, but I have trouble figuring out how to deal with relevancy. If someone comes into relevance I don't want them triggering effects from a cast that ended a while ago.
You can guard it by checking the time
That's how we do it in HLL
Also if you have a moment to talk to our lord and saviour jesus
https://jambax.co.uk/better-burst-counters/
im literally reading that right now lol
For rapid-fire, we setup a timer to repeat the effect, and use looping FX where possible. It fixes the "stacatto" like FX you get otherwise since you can't rely on a steady stream of rep updates.
yeah i've built my ability system a certain way and then decided later on i wanted weapons to be included in the same system, but weapon fire rates are much faster than what I had planned for ability tick rates, so i'm kinda trying to rebuild parts of it to account for this
normally I have a "simulatedtick" function that fires with the tick number (the tick of the ability cast, not like a game tick), and can change effects based on what number tick it is, but for fast firing stuff I'm considering just doing only an initial tick and an on-cancel tick that just start and stop a looping effect
yeah that's sensible enough
so after reading that post, my question is how would you change your approach to handle if you DID care about what number shots in a given burst happened? like if you wanted to know if the burst was 4 shots or 6 shots. Since you're never resetting the counter, you'd need to keep track of which shots started/ended a burst I think
and to add on to that, in my case, I want to know how the burst ended, since I'm trying to repurpose this for a cast bar type situation, which can either complete all ticks, be cancelled early, be interrupted, etc. I was considering some kind of FastArray setup, where the array just contains every completed cast (up to a maximum) represented as a struct that details how many ticks have occurred, whether the cast is still active or not, how the cast ended, and the ability that the cast was actually casting. I'm not sure if that's going to cause weird issues replicating multiple cast structs at once tho
You could use an enum or a gameplay tag to denote how the last burst ended
hmm, like inside the burst info struct have the counter and bisfiring like you have but also have some info about the previous burst? that could be interesting
Possibly yeah. Abilities get complicated though, this one works okay for basic pea-shooter weapons but maybe not so well for more complex stuff
yeah, the more I try to fit weapons and abilities in the same system the more I feel I'm having to compromise to get both working
but there's so much overlap in how they work prediction-wise that I don't really want to have to write a new component for weapons that does 90% of the same stuff
alright well thank you for your time, gotta go to work
Does it make sense to have replicated logic in UAnimNotify/UAnimNotifyState's ?
Or is it the same as with UUserWidget's where you shouldn't use it ?
Just found the answer here xD
really need to play HLL
Hey uhm, since your post told me to make this kind of call from the owning actor, should i do something like this then ?
void UAnimNotifyState_MeleeHitCheck::NotifyEnd(USkeletalMeshComponent *MeshComp, UAnimSequenceBase *Animation)
{
Super::NotifyEnd(MeshComp, Animation);
for(AEnemyBase* Enemy : M_AlreadyHit)
{
if(IsValid(Enemy))
{
if(ACharacterBase* Owner = Cast<ACharacterBase>(MeshComp->GetOwner()))
{
Owner->DealDamageTo(Enemy); // <---
}
}
}
M_AlreadyHit.Empty();
}
This kind of workflows always confuses me so hard
hmm i tend to handle stuff outside of the notifies
and have the notifies call a function on the enemy, as notifies are CDO (can not store states)
Thought that's exactly what i would do when using the Owner to handle this.
Not sure how else i should get the enemies i've hit outside of the Notify
Yeah, that line is probably useless anyways since i'm calling it on NotifyEnd
Even more when it comes to my brain ๐น
Generally you use a notify to trigger logic on the owner. In this case you want the notify to trigger on a melee hit, so you would call a function in the owner to run the check you're trying to do on your character.
Ie, notify ends, run a trace to get enemies hit.
what i am saying isd
I'm currently doing this trace in the Tick of this Notify
^
as the notify is CDO
Actually I think you can store it just fine. I don't see why not.
So should i pass the hit enemies in my tick directly to my character which handles the already hit logic ?
its CDO, it does not maintain state
It doesn't need to
it does if M_Hits is a member
Array created on notify start, populated on tick, emptied on end.
It persists through that
At least in BP versions of notifies I've used.
those are const
^ Is that what i should do instead then ?
Or will i also run into another problem when i do it like that ?
I would just do the logic on your character in the first place.
* We don't instance UAnimNotify objects along with the animations they belong to, but
* we still need a way to see which world this UAnimNotify is currently operating on.
* So this retrieves a contextual world pointer, from the triggering animation/mesh.
* ```
And call that from your notify
@meager spade also BPs can ignore const btw
They'll do some shady shit under the hood.
So also the whole tracing ?
Yes.
Alright, in that case i'm not even in need of my Notify's anymore
i use the notifies to turn on/off the trace
Was probably a tutorial for a singleplayer game i've followed since the trace was also made inside of the NotifyTick
and notify when the melee is finished
So basically just like
void UAnimNotifyState_MeleeHitCheck::NotifyEnd(USkeletalMeshComponent *MeshComp, UAnimSequenceBase *Animation)
{
Super::NotifyEnd(MeshComp, Animation);
if(ACharacterBase* Owner = Cast<ACharacterBase>(MeshComp->GetOwner()))
{
Owner->SetShouldTrace_LeftHand(false);
}
}
Or similar ?
yh
Yeah something like that
Alrighty, hope i get it to work, thanks for the help ^^
This might be a dumb question but I'm trying to check overlaps with OverlapMultiByChannel and I want it to ignore an actor. In the server it works, in the client the autonomous proxy actor doesn't get ignored.
Does this problem ring any bells?
Hello everyone, I'm just trying to change the value of a variable. It's replicated, a character cast to the game state that the triggered action has happend, the game state set this boolean to false for a defined character. It works very well when the client is this defined character, but not when it's the server, the variable still have the same value. My event is replicated on the server, this is the value I get on my specific character
Show your nodes.
Trigger action :
GS action :
(and 173 is a child of the base character, which contain the function on the first screen)
Show how you do it
const FCollisionResponseParams Response;
const FCollisionQueryParams QueryParams(TEXT("LadderEntranceOverlap"),false, Character);
TArray<FOverlapResult> CenterHits;
bool Close = GetWorld()->OverlapMultiByChannel(MovingHits,CharacterLocation,Character->GetActorQuat(), ECollisionChannel::ECC_Pawn,CharacterCapsule->GetCollisionShape(),QueryParams, Response);
something like this, however I discovered that under separate processes works correctly, and in one process works wrong I wish I was able to know why and how to fix it, two processes works slow -_-
For some reason i cant get my server rpc to run on the client. I'm running the rpc from the player character too.
I've done this before and havent had issues
I have a replicated UObject (I had it correctly setup and it was working). I recently changed it to using a struct instead of a FDataTableRowHandle. But now it doesn't seem to be replicating anymore (not calling OnRep). In the image above is the code used to change structs. Anyone has an idea for potential fix?
Rep in the component
What exactly is the problem?
Of course nothing runs on the client, that's a Client -> Server RPC
That should be reliable too btw
Server RPCs dont seem to work from clients. This is UE5, they seem to work fine in ue4
Most things are going to end up portable to UE5. Not worth the headache of finding out what doesn't work just to try and use it right now. If you intend to use UE5, it's probably better just to stay on 4.26 or so for now and design your baser systems, and then spend some time fixing stuff after an engine upgrade.
Oh you said "run on the client" not "run from the client"
Can we use OnReps with Push Model?
So I think I'm having an issue with unreal's game mode functionality. I tried to play in editor using a client / server setup, and started getting random crashes due to exception violations. They appear to be happening when trying to GetAuthGameMode() i'm guessing from the client instance that is running. Does this basically mean I need to change my code so that client's never try to call functions from Game Mode? Or are clients still supposed to be able to call Game Mode, just at the server's Game Mode and not their own?
(i.e. RPC's)
Gamemodes only exist on the server.
ok thanks, yeah I figured that much out so far ๐
so, if I wanted to call a function on the server's game mode class, from a client, i'll have to do some kind of RPC it looks like
Not on the gamemode. You can't call an RPC on an object that doesn't exist.
You also can't call an RPC on an object that you don't own (for clients)
ok, scratch that idea then
The most common method for telling the server to do something is to use an RPC on the player controller or another actor that the player owns.
The server RPC can then do whatever it wants on the server.
ok cool, in my case it would be a pawn controlled by the player, so that should be simple enough
@pearl moon it's also very good practice to check your pointers and don't expect them to be valid. In blueprint, you can do this with an IsValid call, in C++ you can do if(pointerhere) or if(IsValid(pointerhere)
thanks! yeah i've been doing alot of checks for nearly all my references in the game project so far, it's a habit now at this point ... in the case of the game mode, i had just assumed that all clients/servers get a gamemode, but only the server's game mode has authority over the others. In retrospect that makes little sense to me, haha
So I believe what I can do, is do an RPC from the client's gameinstance, which should be executed on the server's gameinstance? The server game instance would then call whatever function needed from game mode, returning the values or info needed to the client.
@pearl moon use the player controller
It exists only on the owning client and the server.
Based on your previous conversations here you should read the pinned compendium first
Lots of this is basic knowledge you can read up on
If you need something to go to all clients, use the player state or game state.
Also that
I, should check pins on channels more often then! Thanks lol...and yeah I haven't touched game or player state classes at all yet.
Is there a way to create Multiplayer Games for mobile?
Creating Games with Multiplayer Steam Subsystem is easyโฆ.but for mobile, i dont have any idea
Hello! I'm trying to implement a jump action for a toy multiplayer RPG game. Basically there are several characters and every player can select them and make them do things (move to point, jump to point, use items, etc.). I made it possible to move using navmesh by making characters possessed by an AI Controller and when you click somewhere on navmesh, the Player Controller just tells the AI one to AAIController::MoveToLocation to the hit result.
But regarding the jump โ do you think my idea for how to make it sounds okay-ish?
- Player Controller uses a Jump() method on the selected character which implements ICanJump interface (so that it doesn't depend on a particular actor class) and does a server RPC
- Server RPC calls a Multicast_Jump() RPC on the character to make everyone else do the jump also
The Jump would then just lerp the character along a spline to the destination point, but every client would do this on their own. I think this would work but I'm not sure how to make the player that initiated the jump ignore multicast RPC from server. I wanted to make him issue the jump immediately so that they don't have to wait for the server response, to make the jump feel immediate. Does this sound ok? Sorry if this is a noob question
On a side note, if you use AI Controller possessed characters like I do, I guess you don't have client movement prediction from CMC, right? Because they are unowned or server-owned actors? It's very hard to wrap my head around the best practices and there is a lot of stuff going on with replication :/
pawns exist on the client, therfor the clients copy of the cmc will do local prediction just fine
How bad is it to call an Server RPC for tracing inside of the Tick method ?
Would only be called if the tracing is actually needed aka player is attacking with a melee weapon
that depends on how many inputs and what kind it has, why can't you keep the trace on the client?
why can't you keep the trace on the client?
Maybe i'm just taking the "Never trust the client" too seriously here ๐
Why do you need a ServerRPC for that?
You can just tell the Server ONCE that you start attacking.
Server can then do the Trace on their own
And it's not bad-bad to call one, but you 100% can't make it reliable.
On Tick only ever unreliable RPCs
While the RPC to start attacking can be a reliable one, since that should only happen once (every other time)
Would this here look any right then ? (Where i only set ShouldMeleeTrace via an Server RPC)
void UCombatSystemComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if(ShouldMeleeTrace)
{
//Do the tracing
}
}
Also not even sure if i should use some authority guards in this place ๐
i see, you need tick so you can trace the arcs of the melee weapon when swinging
Yeah, that's my case
Is that an animation driven one?
You could maybe also just use an AnimNotifyState
And trigger the Animation
AnimNotifyStates have Tick
The animation is used to set ShouldMeleeTrace with NotifyBegin/NotifyEnd
whatever is playing the animation will call the rpc to start tracing on the server
Or you just trigger an AnimMontage via the RPC
And have an AnimNotify State with the correct length in that montage
Isn't that what i would do with the code above ?
Since the animation will trigger an Server RPC to set ShouldMeleeTrace via NotifyBegin/NotifyEnd
My first version has used the AnimNotifyStates Tick to trace.
But i've used too much replicated logic in it since i've stored the hit enemies inside of it.
Would it be fine to have the whole tracing inside of this Tick where i only pass the hit enemies to the owning character which will handle the logic such as Was already hit, Deal damage to it
Otherwise, why even needing an RPC?
You can just get the owner of the mesh in the AnimNotifyState
I think i do trigger the animation with an RPC since this animation state will only run when the player is attacking.
And i set the IsAttacking with an RPC
Why so many RPCs
There should only be 1 RPC needed for this whole thing
And it's the keypress of the player
"I want to Attack"
That's all
The only other thing you might need is a Multicast to tell Simulated Clients to play the Montage as well
UE4 even keeps those synced
I guess that's what happens if a beginner tries to make a multiplayer game ๐
Yeah, i feel that daily atm ๐
And I can fully understand that one can't find this out without getting some answers every now and then
But ultimately, I would start with this setup:
On Key Press, call "TryAttack"
In there, check if you can attack
If so, tell the Server via ServerTryAttack, but continue with your attack by playing the Montage locally.
The Server should just call TryAttack too then
Also playing the Montage, and maybe executing the Multicast
In the Multicast you need to make sure to filter Server and owning client (IsLocallyControlled in the Character would be true for that one), because they already played the montage.
And then play the Montage in that again
You can then have effects added to the AnimMontage, as well as Sounds.
And also your AnimNotifyState "AttackWindow" or so
In there you can get the Owner of the Mesh (I think you get the mesh as an input)
Cast it to your Character and tell your character to trace
Most likely grabbing a socket location + rotation for the actual trace location and direction at the given point in time
That will execute on everyone, so no need for further RPCs
Just limit the actual damage dealing to authority
Rest, like hit blood or sounds etc. can just be executed
Alright, i'll try to study your words and to apply it to my project.
Thanks for the help ๐
Just to be sure here, would the ServerTryAttack basically just call the normal TryAttack method here ?
Oh sorry, you just said it in the next sentence
Yeah I usually do that and then filter specific logic in the TryAttack with HasAuthority or similar
// Server and Owning Client (who pressed the key)
void TryAttack()
{
if (!CanAttack())
return;
if (HasAuthority())
{
MulticastOnAttack();
}
if (!HasAuthority() && IsLocallyControlled())
{
ServerTryAttack();
}
PlayMontage(...);
}
// Server Only
void ServerTryAttack()
{
TryAttack();
}
// Everyone, but Owning Client (pressed key) and Server excluded
void MulticastOnAttack()
{
if (HasAuthority() || IsLocallyControlled())
return;
PlayMontage(...);
}
Just keep in mind that:
- This is "one" way of doing it, doesn't need to be the best way for all and especially your situation.
- "HasAuthority()" does not mean that it's always the Server. In this scenario it does, but a locally Spawned Actor (that is not replicated) should have ROLE_Authority, which would not mean Server.
- The above is pseudo code. :P UE4++/C++ looks different
Alrighty, will also study that.
But there is another question related to you.
Are you available for private(paid) multiplayer tutoring ?
Yeah, let's talk via DM though
Alrighty
If a session dies (server is closed or you lost connection to it) how do I reset the client back to the main menu? (Its my first time trying to make a multiplayer game so I am pretty stupid when it comes to all of this)
It should automatically do that
the netdriver will shutdown and call into the game instance to move the player, though its best to override that kinda stuff and handle it yourself
I dont understand how the game will make clients leave a session and move them to the menu
@red salmon if the client loses connection to the server, the clientopens up the default starting map. You can override it to go to your main menu map if that's not your default starting map
Ok then it must be a problem with how I had done the leave server button.
Hello everyone, I'm just trying to change the value of a variable. It's replicated, a character cast to the game state that the triggered action has happend, the game state set this boolean to false for a defined character. It works very well when the client is this defined character, but not when it's the server, the variable still have the same value. My event is replicated on the server, this is the value I get on my specific character
This is the trigger action :
And this is my game state action
173 is a child of the base character, which contain the function on the first screen
@wise bridge is that bool replicated using OnRep?
err Rep Notify in bps
it could be that the client is printing it before they get the updated value by replication
where is your print?
it never becomes true for the client?
It's perfectly working
But for the client
If the client server is 173, it's not working, he got it on true all the time
what do you mean by client server?
ah ok
I'm not in dedicated server
put a breakpoint here:
and check what the and is outputting
it seems like the server is never getting the call
It is
humor me
I just put what I wanted in the screen, but the OK is printing
Give me a second
When the client is 173 :
I think i've got a terrible bug here, or just me being an idiot.
As shown in the video the client trace is correct, but the server tracing seems to have the enemy at a different location.
The weirdest part is that it's only happening when i play as client only, but when i play as server/client + another client it will trace just fine. Any ideas here ? ๐ฐ
When the server is 173
(I remove the execute on server, my client couldn't reach the GS, but that change nothing)
are you using a dedicated or listen server?
Not too sure what will run with this options ๐
Can only read "A server will be started in the background"
your client should be able to get the GS, they have a locally replicated version of it
what could be happening is that your gamestate is coming out null, so it's spitting garbage data as your actor location
yeah that's fine.
Hum, stupid thing but since I'm checking every frame, I can't use that I'm unable to move
Or do anything
Yes
Oh mb xD
that was for @vague fractal
Basically, i'm getting the location through the hit actor from FHitResult
@wise bridge put a breakpoint on the branch node, and see what the bool output of your and says.
debug the trace then
That's what I did, but it just pause the game every frame ๐ข
I almost never use it, can you explain more? I click on it? I'm using the button on top but I can't do anything with that
nono
the red line going into condition
if you mouse over it, a tooltip will popup with it's value
alternatively, put a print string before it
xD
Kinda having a hard time to draw the trace from the server
Alright
When the server look the client (I don't check if it's scp173 for now, so that's normal that the client is calling)
When the client is looking the server
Everything works all the way to the variable, I see it with my print
what if they see each other?
oh ok
My point is that the value of can move is false on the GS, but not on the character when the client see the server
Beside this it works well
Yeah, there are not the same from what i can see
Avoid cheat
If 173 can say hey I can move that suck
yes
Might be
clients are the authority with listen servers
so, if they're the host, it's easier to cheat
Well only the host
Yeah, but I'm not doing anymatchmaking
For now
Only server community based, so it's don't change a lot
If someone cheat, he will be alone
so let me see if I understand correctly
You have an actor, which determines if the player can/can't move if it's in their view
correct?
Yes
I would just have the actor manage all of this
Well, as I said I will remake this in the future if I do that so no
@fading birch Actually, now when i look closer at all those outputs, the server start/end location will never change.
And since i'm getting those locations based on my "AttackAnimation" i'm getting the feeling that it's cuz the server in the background wont play the animations
no, servers generally don't.
Can we somehow replicate subsystems?
can you give an example?
Yeah, that explains why this only happens when i only play with clients and not with the server/client and another client >_<
@vague fractal if you're executing an action, that needs to be replicated to all clients, calling it from the server is a good spot to do your trace. You should be doing your trace on the server anyways
what do you mean by server/client with another client?
you said you were only testing using Play as Client in PIE
"Play as listen server"
that launches a server in the background for you
ah
yeah, that doesn't play super nice in PIE
because both clients are listen servers
Really ?
I always see that only 1 client is the server while the other one is just a client
you can open the map you're in by typing open MAPNAME?listen on one client
and then open 127.0.0.1 on your other client
oh, maybe they fixed that issue then
Like i mean this names here
ah yeah
that's the same thing then
so, your play as client with both = dedicated server
play as listen server = listen server
on dedicated servers, it's headless and runs in the background and only executes logic of the game server side
listen servers do the same thing, but the hosting client is also the authority and a client at the same time
if you program your game correctly, you can swap them in and out interchangeably
I've totally no idea how to handle this situation then.
Cuz if i can't use my animation to trace i'm lost ๐ฐ
how are you kicking off the animation in the first place?
just execute that function on the server
and have it RPC to your client
think of the client as the cosmetic tool for your game
and your server as the actual logic host
I'm doing it.
It's pretty much just a boolean which allows me to enter an animation state (So the Attacking animation)
ah then you can just execute the trace then and there
you can us anim notifies too
to execute an event when a certain point is reached in your animation
to run code on your server too
ie your trace
Also kinda doing it already ๐
I'm using the NotifyBegin/NotifyEnd to tell if i should do tracing at all
Hi, I am struggling with actor's replication. I want to spawn actor on server and pass some data to use in BeginPlay on clients.
I have following code:
//Server
AMyActor* NewMyActor = GetWorld()->SpawnActorDeferred<AMyActor>( MyActorClass, MyActorTransform );
NewMyActor->Data = "Some data";
UGameplayStatics::FinishSpawningActor( NewMyActor, NewMyActor->GetTransform() );
//Client+Server
AMyActor::BeginPlay()
{
Super::BeginPlay();
print(Data);
}
On both clients and server actor is created and BeginPlay called, but only on Server I get proper string data, while on clients string is empty. Do you have any tips how can pass such data during initialization?
I have checked RPCs but that sucks as Actors may not be replicated on client and rpc call disappear :/
then you're almost there.
in game mode, Data is UPROPERTY( Replicated )
just use your notify begin to kick the trace off on the server, have the server use it's locations as they're 100% correct and boom.
game mode only exists on the server
pointless to replicate anything there
give #multiplayer message a read
so you're spawning them in gamemode
and the data on your actor itself is replicated
actors yes, data not really
No way to do this on the game state?
data not, data is default, not changed to values which i set up during spawning
you can, but having that behavior tied to the actor that is the cause of it makes more sense
if you're setting the data on the server, the client has no idea what that data is. So it's not going to work. You need to replicate it on the actor.
so I need ReplicatedUsing on my Data?
you said you're not replicating your data at all
I want to, I gave property Replicated, and I want to pass data during actor's spawning, not after
I have already
just set it up in the rep props in cpp
stupid me... forgot to expose Data parameter inside GetLifetimeReplicatedProps...
Happens to all of us
ye... imo should be warning there, or even it should be done underhood
tbh c++ api of ue sucks - metaprograming on enums, enormous number of macros, nonconst functions which could be, lack of constructors, lack of constexpr
it does give you a warning when you compile.
I'm sadly lost at this part here "have the server use it's locations as they're 100% correct and boom."
I thought about using the NotifyTick to set the start and end location, but that doesn't seem to be the way ๐
does not, maybe i do not have -Wpedantic or something...
in your NotifyBegin cast to your character or w/e the actor that's executing the animation, call an RPC on the server to execute the trace. In the RPC get the location there.
you may have disabled warnings, ยฏ_(ใ)_/ยฏ
But wouldn't i have to update the location on tick ?
Since it's like a sword swing animation
no, you can just trace every time the notify is hit
if it is done by default :p thanks anyway. Sorry for aggression but that kind of things trigger so much...
i understand
But the NotifyBegin/NotifyEnd will only be called once per animation and the trace should happen between those two notifies ๐