#multiplayer
1 messages · Page 607 of 1
@dark edge an stupid question, I always relay on server, so anything client want to do I always Replicates to Run on server okay, but I never bother with if client get updated, but if server is updated all the other clients will be update too right?
so I always do this
and Throw function just do what it meant to do
Am i doing it right?
Anyone know why a skeletal mesh attached to an actor would be slightly off center of the actor when moving around in Client, but on the server it stays true to the actor's center? A static mesh attached to the actor always stays rigid to the actor's center, but the skeletal mesh seems to be an update behind in its actual world location...though it's attached to the same root.
I'm using the regular character movement component
It's relatively slight, but it results in the skeletal mesh jittering, whereas the static mesh does not
Eh weird, after two hours of trying to figure this out I've solved it..I just disabled gravity on the skeletal mesh, what gives..?
Actually the jittering stopped, but there's still that subtle lag which makes the skeleton mesh look about 1-2 pixels behind the actual actor's position...
no they are not. It's a subtle jitter so it's hard to notice but alongside a static mesh it's more noticable. Would not have noticed if I didn't turn the animations off for testing something else
That's why it's just weird, skeletal mesh on an actor whose position is updating very nicely during replication
for the 1-2 pixels behind it's just a bit weird but I don't wanna go in the depths of the code to figure it out, the jitter was the real noticable thing, and the gravity fixed that
only other thing i can think of is if you have the update optimization thing ticked
yep I unticked that, that also had caused a jitter
that was the UI, and the actor position was jittering, but once unticked that smoothed it up
wait depends on which update optimizatino you're talking about
there's a lot..I unticked a network skip proxy prediction on the movement component to undo the UI and actor location jitter
I've unchecked all sorts of various skeletal mesh optimization boxes to no avail, I don't think a regular game would notice the 1-2 pixel shift of the skeletal mesh, tho, not with animations playing
sorry I'm talking about like 3 separate problems at the same time
hey I have an object with a variable I'm replicating to the client, if I change the variable and call ConditionalBeginDestroy on the object from the server, will the variable get replicated to the client before the object gets destroyed?
UB
i highly doubt it will
i think once they are marked pending destroy, they stop replicating
and actors only replicate objects at set intervals
is there any way to get a variable to replicate before I destroy the object, I want to check the variable when the client's BeginDestroyed is called (or PreDestroyFromReplication, BeginDestroy, not sure which one is the correct one)
Force a netupdate, and delay the destroy
or send a client RPC through the player controller
is there no need to create a session when using dedicated servers & steam? just got started using dedicated servers, and there doesn't seem to be significant discussion about it online that i can find
About hosting a server for dedicated; I assume I don't want to build a linux version for my window's clients to connect too. So I'd be looking for a dedicated server via Azure that handles windows, yeah?
I'
m just playing around, so I didn't want to go hard on something like an EC2 instance or anything
Doesnt matter what the Client is running. Its quite common for Dedi Servers to be built for Linux.
Its usually cheaper to run and slightly more performant.
But that depends on your services that you use and the game of course.
Oh really? huh, how about that.
Point is, a Player using Windows can connect to a Server running on Linux.
Yeah okay, I'll stick with my DO build for the moment.
Now to dig into a Linux build 8\
Does it matter where I install the toolchain? I imagine it would
Would repnotified variable work in offline as well?
If you're hoping the function will be called when the variable is set, yes.
only in blueprints*
c++ properly doesn't call OnRep server side
^ you have to call it manually on server
so say cpp MyServerFunction() { MyServerVar = 56; OnRepMyServerVar(); }
XD
Hey Zlo - After you helped me fix the replication issue. The single player seems broken now. lol. It seems PS_Lobby gets the data but i can't access the data using PS_Gameplay.
single player can't be broken by that, unless you travel a different way
or have some check that prevents it from working
I think i know why - It might be the Transition Map has diff GM than my single GM
Unless I don't have to use the same GM for transition level as the lobby
you can use the same as arrival map too
well
your transition just needs to have the PS_Base for PS class really
i c
In single player I go from main menu -> transition map -> gameplay level. I have first two GM with seamless travel checked.
Mainmenu has PS_Lobby and transition map has PS_Base and gameplay has PS_Gameplay
My multiplayer lobby has two many options that not needed for single player.
I guess only for single player I could use game instance
No I shouldnt do that- that will break my mutliplayer
In my log i don't see seamless travel for single player
I fixed it. Thanks
What are some efficient ways to send RPC's with lots of floats that represent inputs? So far I got this code which is very inefficient and was wondering if someone can give me tips on sending rpc's.
That Happens when l have spliscreen off and l dont know why player mesh spawn when even my gamemode class have none
basic my blueprint spawn them how can l spawn the player only when join in game
Hey guys, can anyone tell me what needs to be done in order to have the client movement replicated to the server? (client sees server moving but no vice versa) i understand it has something to do with RPCs but not sure exactly how to set it up
physics movement not normal character movement, i'm using a rolling ball
@vestal ferry This is a lot harder than you think it is
I mean yeah, you can use RPCs to tell the server that you move
But physics won't simulate the same on server and client
Trying to synchronize them is a fool's errand imho
How can count players that join in server and if they are more than a number they cant join excect that l want tag players they join with a number etc. player 1 join and he will have number 1 as a variable for using in game
hey , have anyone know what my game will connect if I am not tick the "Use Lan" ?
If “Use Lan” is checked the session you create will be only available on your local internet. If I am not tick the "Use Lan" , it means available internet so everyone can join the game ?
anyone and any where they can join?
If you don't tick use LAN you can use something like steam to connect over the internet, you would need to implement a steam subsystem in your game for that, when you do, people will be able to connect to each other via their steam accounts over different networks.
Thank you so much for responding! can you point me to a resource on how this can be done? What about normal character movement? would that be easier to replicate from client to server?
Beside steam , have other platform also can use ?
@steep terrace GOG if your game is there, PSN/XBox if your game is there
EOS is upcoming, need to integrate it yourself or buy a plugin as of right now IIRC
So if i have a game based on physics movement, i can just give up on multiplayer options? how would a racing game work online for example if it relies heavily on physics
If you want true physics movement in UE4 it's a very hard task
You would need either your custom physics engine, or accept that clients can cheat heavily
(Or accept a really shitty experience)
wow, ok, thanks, so what about normal character movement?
how would i replicate that from client to server?
I see, got it. Thanks a lot for the help!
Is that means, if I implemented a Oculus subsystem, I will be able to create a multiplayer session over internet while people can connect to each other via their oculus account? Is the connection a P2P connection or a dedicated server connection?
Sessions are unrelated to the multiplayer architecture
They are a service offered by a particular commercial platform
Servers, or lack of them, is 100% your responsibility
I see, sorry for asking dumb questions as I am very new to multiplayer game.
Does Oculus provide such online subsystem for implementation, so that I can build a multiplayer game running by Oculus Quest?
can l cast with wigfet in gamemode to take a variable?
I think they do have some kind of subsystem like that, you can google it, however note that Oculus is a tough company to deal with, there's a good chance your game might not even be approved it the first place, i'm also developing for VR and the quest seems really far from me at the moment...
Does that work for count and set controll id?
I've a Blend Space 2d that goes from -.5 to 1. I take input move forward connect to server node which multiplies with a multiplier then set the value to movement variable.
The replication works. The only issue is that the owning client sees the animation a little faster.
Ok ,thx a lot
does set controller id??? l go to lpayer blueprint and print a -1
I have not been able to find a single tutorial that shows how to set up online play. I can literally only find LAN tutorials, Can anybody link me to the correct tutorial for this?
LAN and online is the same thing, except for matchmaking
So I should search videos for matchmaking? @bitter oriole
Well you don't need matchmaking until the game works in multiplayer
It's kind of a secondary concern
I know what you mean, I've been using ue4 for about a year now, I know the complications of multiplayer
But I'm a little opposite, I'd rather know online multiplayer before multiplayer replication
I just want to see my friend join my 3rd person template. That is the video I'm looking for
Get your IP address, have your friend type "open <ip>" in console, done
and then after they'd have to search for my session?
No, that command is enough to join
If you want sessions, you need to set up your game for a particular online subsystem
Such as Steam, GOG, EGS, etc
Right, so I'm using the steam subsystem and it works, but that's pretty much where every video stops
I also have create sessions and Join session
Look into advanced sessions plugin
but it seems to only work for lan
yes, that's what I'm currently using aswell
Maybe I'm doing something wrong, I'll start over I guess
@twin juniper So what is the actual error ?
Using Steam has some prerequisites, like two people on separate machines, logged into real Steam accounts
And you need to enable Steam in your project config
And of course, your session setup needs to be correct
@bitter oriole I realize the last time I tried it, I used game session null. I'm assuming maybe that is the reason only LAN worked. oops.
I'm going to test it correctly this time instead of being an ape, my bad.
Yeah, the NULL OSS is LAN only
Feelsbad, thank you
I'm trying to filter packets in wireshark with the help of UE4's "net.MagicHeader 11001010110110110101101001001010" console command (It's apparently supposed to add a magic number to every header of every packet). When I enter the hex value of this string (udp contains CADB5A4A) it doesn't seem to find any packets containing it. Any idea what I'm doing wrong?
Hi, i'm wondering how is designed the architecture of a multiplayer game that use lobbys. I would assume there is a master server to create lobbys and launch new server process for each game ? Or there is tools to do that with UE ? Thanks
@elder sable A typical lobby could simply be your single-player main menu, with a list of the players in the session, before any server had started
A dedicated could then be spun up when the session is full
How players can join the lobby without any started server ?
Or you talk about the game server ?
Depends on what the players actually see of each other in the lobby
Mhh, just names, but they need to connect to a server to join the lobby, no ?
No
They just need to join a session
You then fetch the list of players in the session with their info
Ok so the session system is using a server ?
Maybe
Who cares ? It's a service provided by your sales platform
Ask Steam how they implement it
If i want to make a custom server for lobbys i should care no ? :p
Why do you think you need a custom server ?
Just to know how it works
Well, ask Steam, GOG, PSN etc how they implement sessions
On the game development side, there isn't much to know about it
Mhh ok, thanks
If you need a lobby, just join a session, fetch the list of players in the session, display it in a menu - you're done
Sessions could be created by dedicated servers when they launch
When the session is full, players would travel to the server to actually play with the others
The only thing you need is a service that monitors the player population and starts new dedicated servers
And I mean, you don't need dedicated servers, if your game isn't PVP, listen server works fine
Ok, so i have to make the service myself or there is existing tools for that ? (it s for pvp yes)
I think there are services that do it, but you're probably better off doing it yourself
Ok thanks !
I usually advise to stay away from PVP and dedicated servers but hey
Because you'll be paying for dedicated servers years after your sales have dried up, and you'll need a dedicated team to maintain these servers, keep them up to date, prevent them from being hacked
On the client side you'll be spending 50% of the budget into anti-cheating
And you'll likely have 5 online players at best
i just make a simple game to learn
Yeah, that's why PVP is not a great idea
Unless it's never going on sale of course
No it s just to learn and see how it works :)
Cool then
If I need to disable player input from the server (player is stunned)... how do I go about it? The controller only exists clientside 😦
It does not
Controllers exist on the server
And pawns have a method to enable or disable input
do I have to notify the client that his pawn got disabled? or disabling it in server disables it in client? :S
Depends on the game
I would like to create a FPS multiplayer game with around 20 people joining into one session using the online subsystem running on oculus quest, did anyone have any experience on how serious will the latency be? Will 20 players be too much for a game session? What are the factors that will affect the latency?
Does anyone know if it's possible to call an RPC on a specific UniqueNetId?
I'm trying to generate login tokens on the server for Vivox when a user connects with Steam, and then send them the token
ClientRPC via their PlayerController
I was thinking that it made more sense to keep all of this logic in the GameInstance because it should only run once at the start of the application, but it doesn't seem possible I guess
Should a cast be called in a UMG function binding or is that too resource intensive?
The cast is attempting to return a replicated array of structs.
idk where to put this but im trying to find the culprit to my game's poor networking
@rich hare UMG shouldn't have any bearing on your networking. UI should only ever accept player interaction to do things to in game objects, or display information from in game objects that have already had properties replicated to them. Using them like this should disconnect them from most forms of networking issues sans someone spamming input for some reason. Both that point and casting lead this to be a client only problem. Whether or not you cast to get your information depends highly on your setup and what this widget is for. Casting is only bad when you have to factor in encapsulation. If this widget is casting to just one thing and that thing is already in the level or whatever, it's pretty much free. But casting to multiple things in one class, where there's only one of them loaded at the moment, leads to all of those others being loaded when you create this widget, and if those classes cast to things, and the classes that they cast to cast to things, all of this gets loaded in a chain reaction. This is fine if these are commonly used or very small classes. But that is where you actually pay for casting, not in the call itself.
Thank you, I knew event tick and umg property bindings were similar, I just was trying to figure out the difference between their update frequency. Luckily now I know What casting does with the system's memory.
@rich hare There's really no difference between Tick and a UMG binding. They are the same frequency. In fact this is one place where tick is slightly better if you're using multiple bindings, because each binding incurs an overhead just like tick does, but usually you end up with more bindings in a widget and just one tick.
5 Bindings vs doing stuff inside 1 tick is expensive
in our prototype widgets we used bindings, our entire HUD UMG was running around 1.1ms
i cleaned it up, removed all bindings, used tick where i had to, and it runs around .13ms
what's the most basic way to create a Coop with Host joining?
hi guys,can someone help me how to set a good replicated linetrace (server side) for a multiplayer shooter?
To be accurate both side?!
thanky
Hey guys, does unreal handle redirects for HTTPS request. I am hosting an Image on my s3 bucket and while downloading from this from the link, it has libcurl error 35.
Hey, got a question
why can`t I still move through this rock
I did change the colision with functions first but after seeing it didnt work
I made it as in default
so shouldnt be a replication issue or such
but I still cant move through ? ?
I tried making it ignore everything as well
Does an AActor's Instigator affect replication in any way? I'm trying to store the firing player's pawn on a projectile to send events back on collision, etc.
I wouldn't think so. Are you having issues when setting the instigator? I personally do this on my projectiles and haven't experienced any issues.
The FPS template relies on character, which is replicated, and is the most massive part of multiplayer
Maybe weapons aren't though
nor the arms likely
I'm not having issues, I just wanted to know if this would cause any. Thanks for the help!
Question on Garbage Collection at the Replicated Level.
I have a system that requires us to manually set the Names of Actors on Spawn Time [Undo-Redo actions]. My question is that if I destroy ActorName_1 on server, then I need to make sure that GC runs before I re-create another object with name ActorName_1.
However, how does it work at the client level? Will clients crash since GC is not manually ran on their end? If so, how do I turn around it/prevent them from happening?
doing killfeed with multicast rpc is a good or bad idea?
@dull lance i would just have a static int running for names and never reuse any
just in case
exploring a question like that is time consuming
Okay. I will look into alternatives to syncing GC states 😛
what I could do is also have actors get Destroyed in a controlled fashion, and make sure that Undo(s) can only run when both the Clients and Servers have cleared GC
I kind of already have smth like that in place, where objects on bulk get destroyed an X # / frame
then have an onRep variable push at the end to force GC locally
that sounds like fast array job
I'd just have an integer tbh
otherwise you'll end up with a race sooner or later
Since the destruction happens on server only by a pool manager
ah
on destruction cycle end, Integer++; OnRepInteger();
client wont appreciate you replicating an actor that has same name as existing actor
however you onrep runs separately from the bunch destroying the actor
and if destruction labds second, forcing gc run does nothing
That is true
I hadn't thought about that.
Hmm. I could have a separate map with <Name, Pointer> (as the only one that cares about the ID system is the server)
Does anybody know if I've created a multiplayer game, where everything is created for dedicated server and many moves are connected through multicasts. is there a way for the client to become the dedicated server in such maps like a training map? So I don't need to have a server hosting "tutorials" and "trainings"
tutorial can be standalone, if its not networked
client can host the game as a listen server as well
if you are connecting everything through multicasts, you should probably start over
Hey Zlo - were you ever be able to replicate root motioned based locomotion? I found a way to replicate it properly but on owning client the animations appear faster.
not something i know to solve off the top of my head
Would bitfield packing only be used in the NetSerialize overrides for structs or would you consider doing it outside of the NetSerialize for instance on a normal uint8 property on your character that gets set to replicated?
No I don't believe so. If you want to test joining things over the internet I believe you need to package your game or run it in standalone.
If you want to test over just LAN, then editor works for that.
Oh, no that is possible. If you create your game with the listen server model, then the player themselves become the host.
I'm not really sure what you are asking. If you want to have a server host players, then yes build a dedicated server to host them.
Those are two entirely different things. You will need to build a dedicated server for one, and the other will just be the normal listenserver implementation. I've never heard of anyone doing that specifically, but I'm sure if you share a list of matches to join you can probably have the host decide what it needs to do as far as deciding if it's a dedicated server or not.
The code difference between listenserver and dedicated can be very minimal to get it working, but I believe dedicated you're not going to want to play animations or sounds etc. etc. It does sound like a lot of unnecessary extra work instead of just choosing dedicated or listenserver.
I personally have a listen server setup for now so I can't completely speak to the effects of the dedicated server, but I do believe you can set it up the way you want it, in the same project. Then, when you build your dedicated server from source, the dedicated server version of your game will run on it just fine.
Yes, you are correct in that a dedicated server has no client. It's basically a command line prompt running game logic and communicating to connections the same way a listen server would.
I haven't myself put one together, but I would assume that if your code works on the listen server then it should basically work on the dedicated as well. Maybe someone who actually uses dedicated can speak to this effect?
Is this current conversation done? My bad if it's not.
Oh ok
I just wanted to ask about calling RPC's efficiently. I want to send RPCs to replicate my pawn's movement. I want to send inputs in the form of floats but I am not sure of how to do this without flooding the server with RPCs. If anyone can give me information or tips that would help massively!
Why are you sending input in the form of a float? Is this an analog stick input?
Well that was just what I am thinking right now. It is not a analog stick input. I was thinking of like sending the axis from my Move functions
I'm still confused. Why are you sending an axis as an input?
Explain what you are trying to accomplish
Yea just forget about that
I just want to send inputs in RPCs as efficiently as possible
Ok, well that still doesn't explain much, but let me give you a scenario then. I press W, so I want to move forward. I send one RPC to say move forward. That's it. When I lift my finger I send another RPC to say stop moving or basically Move(Direction) where direction is 1 or -1 in the forward direction of the pawn.
Or 0 in the case that you have stopped moving.
Now do the same for A and D. RPC to move in a direction relative to the right vector of the pawn either left or right using a 1 or -1
I'll try that in a few hours when I can get on Unreal Engine 4
Thank you though!
Is it fine if I @ you with what happens?
Sure. If you have have issues though I'd just post here and someone will help you.
Oh ok. Thank you! Online there is nothing about calling RPCs efficiently so this means a lot 🙂
As far as being efficient, less is more. If you have to call an RPC for input continually due to analog values changing, you can create your own rate at which you send them up and also send them unreliably. There's no real need to start optimizing or sending efficiently though unless you are having serious issues.
True
But what you say is a really good idea
@winged badger thank you
I want to shift my main focus from gameplay programming to online/network programming. I know I have to have a thorough understanding of the UE4 networking framework and online subsystem, but is there anything else I should start learning and dive into? I heard of an application called PlayFab that enables developers to connect their games to their online services, but it's separate from Unreal's online subsystem, so that's something I can look into learning. I think I should look into where various companies get their online services from and learn a few of the popular ones. What do you think my approach should be? I'm taking my Networks course during the next Fall semester but I want to start learning stuff beforehand.
Thanks
My suggestion is to first understand that how you plan the architecture of your application is almost totally different from an offline one, and to try to find as many flaws to your current method of local programming; networked frameworks will punish you much more for those
@uncut atlas
Thanks @dull lance
Hey everyone, so I'm planning to add player created levels in my game.
i created the level editor and all the needed information is stored in a struct that holds essential information and an array of structs.
The problem is that i need to make the levels players created visible to others and I'm not sure how to do that.
I heard about using a cool free plugin called vaREST to store the information in an online database but i'm not sure if that's the best way to do it.
I would love to hear any ideas thanks.
I have a very general question, but I've heard there were some changes to networking in UE4.24. Is anyone familiar with these? Specifically, after upgrading our project, we are now getting net corrections all over the place. I've tried isolating as much code as possible, and tried profiling as well, to no avail. I've managed to gather some info here but it's inconclusive. Vague question I know but I'm mostly just looking for some place to start my search here
@cosmic pollen If you just want one, use GetActorOfClass, not GetAllActorsOfClass. You also really should use IsValid on pointers before using them.
@kindred widget l need for each pawn that spawns
But you're not doing it for each one. You're only doing the last one in the array with what you posted.
- You probably don't want to do a "get all actors of class" every tick as it can be a very processor intensive command depending on the number of actors.
- If you need to iterate every actor, then you should connect your "set epi" node to the "Loop Body" path rather than the "Completed".
- Don't go across execution paths with variables like in the below screenshot. Pass the reference you need between events.
This is closer to what you want I'm guessing:
but how l can count the players when they join without tick?
player controller is set automatli for each on who spawn?
Everyone who joins a game is assigned a player controller when they connect.
The reference to that player controller is provided in the event above.
If you wanted to keep track of the # of players, then you can add them to an array.
big thanks
If you want other players to see this value, then you need to replicate it to them, which means storing it somewhere like in the game state, and then they can read it from there (as in multiplayer clients do not have access to the game mode)
thank u l understand it
u just solve all my problems
event tick is so bad to use it everytime
hey
i'm using this method to spawn and assign weapons to players
but when i run the game, TruPrim is set to "Hello" for some reason
well the weapons also do not fire
and plus
it wouldn't be doing that unless it had no other option
So, given that ChildActor component seems to be broken for multiplayer (if it needs to replicate) do you guys have any suggestions on what to use instead? Anything built in?
Or do we need to write something - e.g. a placeholder mesh which spawns an Actor at runtime (but only on server lol)?
how can l add widget when my player logins
@silent valley ChildActorComponents are largely useless anyhow. All they are really is a component that spawns an actor and attaches it to the component. You can get the same funcitonality by simply putting a pointer to the actor type in the actor you're attaching it to, spawn the actor that the childactorcomponent normally would, attach it to your actor with the pointer variable and set that variable to that actor. This is even the exact same in multiplayer since all you would need to do is do this on the server, spawn a replicating actor, attach it to a replicating actor, and set the replicated pointer to that spawned actor.
I want to make sure the artists can preview the look without having the Play each time, but I get your point.
Like positioning the dynamic chests within a large blueprint actor.
Or turrets, etc, etc
wWhen i drive my vehicle(as client) it goes a little harsh, like when i turn it isn't smooth, it's like the game is running at 60 fps and the vehicle at 15, probably because server is computing it, how can i make the server put more attention to the client, as the server player in my game will always just hold a turret
How did you implement networking of the vehicle ?
UE4 doesn't have vehicle replication out of the box so that's something you did
Well then, there is simply no multiplayer support there at all
how do i add it in?
Through great effort
are these vents running on server right now?
or client
and what do they need to be running on
server?
all input is always client
What you need is a full movement component that supports multiplayer. That includes autonomous simulation on the client, sending the input to the server, have the server independently simulate the inputs with smoothing, send back the simulated vehicle state, reconcile that on the autonomous client (rollback/replay). Remote clients can play an interpolated version
No physics
Apparently the newish replication plugin thing has some basis for that kind of stuff
ill check it out
its 2 versions off from being completed from what i hear
[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
[OnlineSubsystem]
DefaultPlatformService=Steam
[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
Whether it ever will is subject to many different features - deterministic physics with Chaos, notably
Can someone help me figure out what's causing a crash?
Reporter says it is an Exception Access Violation, and the last thing in log before the error is StartLoadingDestination to for the map.
There are three clients running in standalone, the host and one non-host can load into the level just fine but the third always seems to crash.
Exception Access Violation is almost always dereferencing a nullptr
Attach the debugger (to the third client) and it'll break at the problem location
Can you attach debugger if you're not running a C++ project?
Hmm, probably not. But it's pretty hard to find crashes like that without it.
Okay. I made changes to a couple of blueprints.
Since its crashing directly after loading the map, and this isn't the host, I can rule out gamemode causing it?
Honestly without a Callstack or something, it's mostly going to be speculation
You can attach the debugger to the engine
Ah great, I've never done it without a CPP project
It doesn't need to be a C++ project
You just need the engine debug symbols to make it make sense though
And of course being a Blueprint project means this might be tricky to debug
Is there an event when player controller, player state and game state are all initialized?
I'm doing something on beginplay in the controller but sometimes the playerstate is not ready yet
I believe you can use PostLogin... I think that runs from gamemode, which should be server only.
It has an argument of Player Controller (the player joining) which you should be able to access player and game states from if I'm not mistaken.
I'll try
If it's client-side then no there isn't, you have to wait for the actors to replicate
Controllers have an OnRep_PlayerState() you can look at
alright, thanks
is that bp available?
nvm, I'll do it in C++
i know instance static meshes aren't replicated but how can i get the server to spawn a instance static mesh on the client
@slim matrix could create an event dispatcher and assign it on the client
so would the server do a run on server function then run on client function to trigger the event dispatcher
you call the event dispatcher on the server and on the client you bind it to an event that is set to Run on owning client or Multicast depending on what you're trying to do
Hey.. I want to create an event in C++ that is bindable in BP.. Is that possible? And could I do it like this? DECLARE_EVENT(ADominationPlayerController, FPlayerControllerInitializedEvent) where FPlayerControllerInitializedEvent extends TBaseMulticastDelegate_NoParams< void > ?
use DECLARE_MULTICAST_DYNAMIC_DELEGATE
Then mark it as UPROPERTY(BlueprintAssignable)
thanks
Hm, could I just do a BlueprintImplementableEvent? Seems much simpler for what I'm trying to do
yes
or BlueprintNativeEvent if you want a default C++ implementation that is ignored if BP overrides the event
ok, I just built that but the event doesn't seem to fire.. Is there anything I need to be aware of when calling the event? Or just call the function I declared?
oh wait, gotta check if that even fires on the cpp side
hmyes, fine on cpp
I've never had a problem with BlueprintImplementableEvent not firing...
check the Log output it will complain if it can't find the function
hm, can't find anything
// .h:
UFUNCTION(BlueprintImplementableEvent)
void OnInitialized();
// .cpp
UE_LOG(LogTemp, Warning, TEXT("FIRING ONINITIALIZED!"));
if (bGameStateInitialized && bPlayerStateInitialized) {
OnInitialized();
}
https://i.imgur.com/fVr5qzA.png
This should work?
yep. I'd suggest putting the UE_LOG inside the if statement though :)
if you have editor symbols you can step into OnInitialized() to some degree.
oh! haha
one sec
ah.. game state is not replicating
there is no OnRep_GameState, god f.. how do you all know when the game is ready? I can't be the only one wondering how to know if the playercontroller is fully initialized
there's functions on the PlayerController you can override, and also for GameMode
depending on what stage you want to know about
@silent valley which functions? I've looked into the source and I can only find void AController::InitPlayerState() that has if (GameMode == NULL) though so I can't rely on gamestate being initialized there
trying to find out where gamestate is instantiated
on client or server?
I was checking my net profiler, and this was a 90 second session between two people in an action game
are these numbers "unnatural" per say?
i feel that it might be pinged too many times
APlayerController::AcknowledgePossession(APawn* P) should be called on client AFTER gamestate is initialised
but there's a ton of different functions which can be overridden and honestly it's very confusing and you just need to try a bunch of things 🙂
perhaps i could provide my netprofiler file and i could get some peer review?
I mean the whole thing shows about 1.5KB per second which is perfectly fine by overall volume
The most replicated property replicated 30 times per second
It's hard to say anything about it
there is still some underlying problem and i can't put my finger on it
if its not replication then it might be rpc's
if you're curious i could dm you the profiler file
Look
What is your actual issue here
Did your Wi-Fi router explode ? Got banned by your ISP ?
Gameplay problem ?
My internet is fine, but for some reason testing anything with a total ping of around 50-100ms feels like 300+ ms
How are you testing the 100ms ping ?
I either test with someone over steam or artificially inflate with console commands on my own
So which console commands did you use and how did you measure the response time in the game itself
If you want to test with latency I recommend using an external program too, like Clumsy
The built-in packet lag can be confusing, so it's important to be clear about what you're doing
in the editor i use net pktlag and have stat net for information. I understand that I have failed to consider things like packet loss or rollback situations
So first off - pktlag is not ping, it's lag
100 lag means 200 ping
Plus the frame time for the server
If you're running at 30fps, 100 pktlag gets you close to a 300ms overall response time for the mouse-click-to-video-response time
so it's not "hold the packet for x extra time" but "increase lag by a factor of x"
No, it's exactly what you said
Except I'm guessing both server and client are doling it
PlayerState class has a ping value that is accurately measured, you should be using that to confirm which ping value exactly you are physically getting for your experiments
ok got it. is there a github repo for clumsy? And do you recommend any other network stress test software?
Clumsy you can get here: https://jagt.github.io/clumsy/
It's handy for packaged builds
But it does work for the editor too
Hmm.. Player Controller maybe?
Or do you want it to be entirely local?
It is purely a local thing?
You could use UWorldSubsystem if so
If you don't need network functionality I'd go with UWorldSubsystem
Very handy for managers etc. that share lifetimes with the world itself
UWorld is kinda the "map" basically
Contains all actors, ticks everything etc.
Yeah, and the old one would be torn down with the old world
you could load load an actor on the client that has replication disabled
They have some useful functions like ShouldCreateSubsystem(UObject* InOuter) which you can override to limit to certain worlds etc.
I've overridden most of my world subsystems to only be created in Game worlds for example (i.e. not the editor world)
Annoyingly UWorldSubsystem isn't documented here, but it was added in 4.23
https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Subsystems/index.html
Ah... kinda is the answer
You can totally expose them as a Blueprint you can make a subclass of, but you need to make sure your override stuff like ShouldCreateSubsystem() etc. to make sure you don't get both the C++ one and the Blueprint one
By default it'll just create an instance of every UWorldSubsystem you have
yeah
Ah it will still load the abstract ones, but again you can guard against that
This is from my base "World Manager" class:
{
if (GetClass()->HasAnyClassFlags(EClassFlags::CLASS_Abstract)) { return false; }
if (Super::ShouldCreateSubsystem(InOuter))
{
if (InitializationMode == EHT_WorldManagerMode::WMT_NonDedicated && IsRunningDedicatedServer())
{
return false;
}
// TODO: Don't create if transition level
const UWorld* lWorld = Cast<UWorld>(InOuter);
if (lWorld && lWorld->IsGameWorld())
{
if (InitializationMode == EHT_WorldManagerMode::WMT_AuthOnly && lWorld->IsNetMode(ENetMode::NM_Client))
{
return false;
}
if (InitializationBlacklist.Num() == 0)
{
// Create if nothing in the blacklist.
return true;
}
else
{
// Create if the blacklist allows it.
FString LevelName = lWorld->GetMapName();
LevelName.RemoveFromStart(lWorld->StreamingLevelsPrefix);
return InitializationBlacklist.Contains(LevelName) == false;
}
}
}
return false;
}```
Just with some handy basic settings/enums I've made for it
Actually I might just upload this class somewhere, I've found it pretty useful
I'll tag you when it's up 😄
@chrome bay that prevents that extra SKEL_ class from being instantiated in editor?
AFAIK... yes. Though I've only ever used C++ subsystems, I've never tried to Blueprint subclass one before
i did try the blueprint one once
but there was extra editor specific instance that was just annoying me too much
so i just pulled what i needed from singleton instead and gave up on BP subsystem
Where do those SKEL_ / TRASH_ prefixes come from? Is there a specific object flag for it?
not sure
i knew, but i forgot
not entirely sure editor would work proper if you prevented them from being instantiated either
I just discovered a REALLY strange bug.
- Create new blueprint with static mesh component 2) Set static mesh as root 3) Set replicates true for actor and static mesh component 4) In BeginPlay of character, add switch authority and spawn this new blueprint 5) Attach spawned blueprint to mesh component on any bone with SnapToTarget
Now, on the server and every client, that newly spawned blueprint is attached to the characters hand. Works well.
However, if you change the scale of that blueprint's root component (static mesh) so that it differs from the SpawnTransformScale, all of a sudden, the attached actors are no longer replicating to any of the clients
Actually, the blueprint DOES replicate on the clients, but it's location is WAYY off
I've re produced this multiple times, there's definitely something weird happening with the engine
4.26
I am going through some pretty extensive tutorials for multiplayer and want to level set for a moment. Currently I am going through exercises to remedy rubber banding through client side prediction until the server returns the actual location. The idea being that we roll back if there is a difference between the two. Is this the going standard for how to do this still (by hand I mean) and is that something you still worry about when use are using built in FPS characters?
Hey,
I'm having an issue...
Inside the comment box, Im setting an array with player data. When I print the values, it show the values that are inserted, which is good.
BUT below the comment box I'm trying to get the data from an Index, but it doesn't read the value that it's supposed to ...
Can anybody help me ?
Hey guys - I got a problem - I want to receive a variable from Server to Display in a Widget: e.g. PlayerID - demand via Function - raise by one on server and receive
someone got a clue?
Either mark the Variable Replicated and use a ServerRPC
Or use a Server RPC and then a Client RPC
Functions can't do that, only custom events.
ty will try
Hello does anyone know how i can launch character in multiplayer?
You mean via the LaunchCharacter node?
yea
Just call it on Server and Client
So i have to do two custom events?
which variable need to be replicated?
ActivePlayers for example
ok and then an event in the widget to run on server with incrementing the variable right?
Has anyone ever used or have experienced with a UTimelineComponent? I was running through a scenario where I was setting up a bunch of FTimelines, and I stumbled across the fact that UTimelineComponent has an OnRep callback. Anyone know if this component replicates if set to replicate in UPROPERTY?
All components replicate when set to replicate
But yes it has replication support beyond that
When I create one in code on my character, I go to the viewport and click on it and the details pane is empty. I assume that means if UPROPERTY(Replicated) makes it rep, then everything else just works out of the box? The claims for the BP check box is that the timelines will be in synch across clients.
I dove deeper into the component itself and they are using UPROPERTY(ReplicatedUsing=OnRep_Timeline) FTimeline TheTimeline. Which I am fine doing instead of using the component. I'm just confused though as I don't see how this does the same thing the blueprint version checkbox says it should do: "If active, the Timeline animation will be replicated across clients."
I'm not sure what you're asking
I'm trying to find out if I can just use a Replicated FTimeline to play animations across all clients simply by declaring the FTimeline as replicated.
Because the BP version claims that is all it takes
It would be extremely nice to just play the timeline animation once and have it replicate
Per epic: Timelines must have replication enabled via the Replicated option in their properties. This will replicate the server controlled play position, rate, and direction to clients. This is a basic implementation that may evolve as needs change. Most timelines will not need to replicate. Like any replicated gameplay object, replicated timelines should only be directly manipulated on the server (start/stop etc). Clients should only look at the replicated play positions but not attempting to alter the timeline themselves. In between replication updates, the client does extrapolate play position.
But to me, there is no bReplicates on the FTimeline so I'm quite confused
FTimeline is a dumb struct
It's never going to have a replication flag
The component does
But the component does not. There is no option to set a replicated bool to true.
It simply automatically UPROPERTY(Replicated) the timeline on the component, but I'm unsure how that's replicating the rest of the information you would need.
It seems very black boxy to me and I'm trying to figure it out
I mean, you could start with the doc, tick the replicated bool on the component and see how it goes.
I was trying to keep everything in code instead of creating the timeline in the viewport because I need access to the timeline in C++
Ok. Now I feel stupid. It is just a dumb struct, so by setting an FTimeline to replicate it essentially replicates all of the properties that aren't set to notreplicate.
Yes
Cool thanks for rubber ducking with me 😂
@dire dragon where are you calling the server rpc from?
Mine dont work either unless it comes from an actor that owns a network connection to the server, such as a player controller
I've noticed that when seamless traveling from one GM to a different GM with different player controllers, when calling GetWorld()->GetFirstPlayerController() on the client AFTER seamless traveling, it returns the player controller from the previous map
Makes sense
Is there any way to get the local player controller that is being used on the new map?
Other than the 2nd index
Which I'm sure would work but is mega hacky
Which player do you want, the new controller for the hosting player on a listen server ?
This is in a non replicated actor on the client btw
The new controller for the joining client
You need to wait for the handover to happen and get the controller at that point I guess
Ah I see I'm calling GetFirstPlayerController too early
In that case I'll probably have to make this actor replicated and just do the server RPC from it
Other than calling a server RPC on the GameState from the clientside actor which seems wrong as I've never really seen RPCs being called like that on the GameState really
It's not just wrong, it's impossible
You can't get the GS pointer in the actor and call an RPC on it?
Ah without an owning connection on the clientside actor it won't work?
yup
Interesting, I guess I'll just make my clientside actor replicated
So I can directly talk to the GM from it
Rather than going through the PC
@steel vault Thank you. It worked perfectly.
hey, anyone has tutorial on multiplayer-replicated head rotation?
When my players look around, their looking rotation is set on the server and unreliably multicasted to the other clients. I want to reduce the amount of times that the looking rotation is sent to each client depending on how far away that client is. How would I achieve this? I don't think that multicasts allow me to discriminate like that
Look into network priority. It affects everything for an actor, but may be what you want anyway. https://docs.unrealengine.com/en-US/InteractiveExperiences/Networking/Actors/Relevancy/index.html
Information about Actor relevancy and priority
I have a question if anyone could answer that would be great... when i start my game in listen server my character on the server will lose his camera and just sit there and cant do anything but the clients will get there cam and will start to move but sit in one place just bouncing forward and then back.... any advice...?
@hollow eagle NetCullDistance won't work, as I want the client to receive updates at a distance, but less to save bandwidth. For example, when a client is close to a door, I want the doors rotation to be sent 30 times a second. When he is far from the door, it can reduce to 5 times per second
I see that, although, I was hoping to use exact updates per second, rather than a ratio
Still gives you a starting point to look into
How can I access players and controllers from level BP?
If there is a specific option for what you want, it'll likely be related
Does it work to replicate SaveGame objects? I seem to have bad luck replicating anything that's not a primitive like an Integer or String
or Float
(or vector)
My widget text function doesnt work for all players but for only first
@summer tide Those are actors that are often spawned after gameplay begins in the level, rather than placed in the level, so you cannot create references to them beforehand in your BP graph the way you would for actors placed in the level. Is that the problem you are having?
The level blueprint is best used for things that already exist before the level begins.
So Perhaps it is better to solve your problem with logic in the actors that will be spawned into the level after it begins play, instead of putting that logic in the Level Blueprint
It depends on what you're trying to achieve
@cosmic pollen Is it a widget component added to the player pawns, or something else in the level world space, or is it something in the viewport / UI ?
Hey everyone, i added a sitting animation to my test game and just would like to ask if i am doing this right regarding of replication?
First image: character blueprint setup
(Pressing "Insert" -> Set character blueprint variable "isSitting")
Second image: animation blueprint setup
Setting "isSitting" from animation blueprint to the value of the one inside character blueprint
the animation blueprint one is hooked to the "Animation Update" stuff
EDIT:
Just checked many youtube videos looks like most of them do it the same way or with Animation Montages
So i edit my question: Should i do a pose "sitting" with a montage or like i did it above inside a state ?
my widget return node doesnt works for others exect the first player cab sineibe geko.
help
@cosmic pollen Game Mode only exists on the Server.
If the other players are network clients then Game Mode does not exist for them. You probably will see "Accessed None" errors because of that.
I am actually working on this same problem in my current project 🙂
@peak star ow
this is because Game Mode is supposed to contain the rules of how to win the game etc. And so clients shouldn't be able to access it and cheat
if l fix it somehow l will send u
OK
I mostly solved it on mine too
I have GameState tell the other players by replication or multicast whenever that number changes, and then they update their widgets
Game Mode does NOT replicate
but Game State does
Also GameMode cannot multicast because it doesn't exist on clients
It can tell another actor to multicast though
@peak star l used ur way and count on widget not on gamemode with getall->PlayerState->lenght
@peak star ty mate
Glad it worked out for you 🙂
GameState->PlayerArray->Length is even better
That's a built in array of all PlayerStates that have been replicated to that device
i have a question im new can some one explain this to me how do i get the one with a circle mine is only showing with the heart widget whats the difference?
@cosmic pollen I also found that GameMode has a GetNumPlayers function that counts all active non-spectator players. You can pass that to a variable or RPC on GameState to inform the other machines what the playercount is, minus spectators if you're using anything like that
@peak star intersting but for now l will stay with playerstate 😄
@peak laurel Looks like you're referring to a Class of the widget (the definition of what all widgets of that class should be like) and not an actual live instance of the widget that has already been created. This shows up as a purple pin/wire in BP.
That's why the input pin is purple and the return value pin is cyan. The cyan one refers to the actual object that gets created based on that class. Then you can do stuff to the object now that it exists, and it should be the heart icon if you used a Create Widget node
If not then you might need to cast the cyan pin to a User Widget first.
Gotta go. Past my bedtime
Is there any tutorials on how to make root motioned locomotion using anim montages for multiplayer project? I'm having trouble smoothly running the walking/ running montages when I press a key
god the replication for ue4 is horrendous
I've used this system for 2 years and I think its reaching my breaking point
roll your own networking solution then 🤷♀️
Hey Guys, i have set up a listen server and have an input problem for my character, to debug it - i put an event tick with print string on the character to see if it even, when the server connects it can move and the event tick prints the string, but when the client connects it doesn't recieve input and the event tick doesn't fire, any ideas to where to search for the problem?
Hi Guys do you know how to Scalable Servers , Advanced Matchmaking , Anti-Cheat System and Database System in ue4 without that overpriced plugin in the epic games store . You can take time to give me an answer . If you can answer plz DM me .
l have create 3 mesh that want change matierials but clients only doesnt remeber previous players materils and they dont change either
only the one who will join after them
Lol you're talking about probably hundreds of hours of work there and you're complaining about spending a couple hundred dollars?
You need to take it one step at a time and do a lot of research on each topic, there's no answer anyone can give you that will enable you to do all that simply.
Hey guys! I am having trouble with advanced session. I have two problems;
- I can't join a session.
- Also I did not receive anything after invitation. Only I can see from steam overlay friend chat. Show friend UI doesnt work also :/
Do you have any idea? Thanks! 🙂
@twin juniper i'm not sure if you can apply/cause damage from null source/causer or null damage type
but how are u getting the damaged actor and control variables ?
also does your damaged actor implement OnAnyDamage?
@lusty sky I have been ripping my hair out over this, I found out this is only failing to work on dedicated servers. Damaged Enemy isn't returning anything and the method I use to get the damaged enemy is by collision overlap
Someone in the unreal forums said "set "Mesh Component Update Flag" to "Always Tick Pose and Refresh Bones""
That seems to work for everyone. But I don't know where that is, and I can't find it
i think i did it in some testing projects where i add impulse to an actor and when it hits a character it deals damage to the character
it works on dedicated server i did it like this, it should be same idea with box collision when player enters that box :
Actor that will receive damage :
Actor Dealing Damage
@twin juniper
the wires are messed up i was just testing it lol
No problem I understood it, I'm going to try to
I set up my collision this way
I'm going to try it your way and see if itworks
My blueprint doesn't work Somebody help?
I'm pretty sure you don't need switch authority there
ok im try delete switch authority
just call the server dash
and then the regular dash
you don't need dashevent client only
just call dash
^ that's what i'm saying
but if i delete dash event client only then server Client when dash it try to move but it goint back
Action Dash -> Dash -> ServerDash -> Dash
show us your nodes
delete the last dash
(dash event is my dash)
show me your dash event also
what is Moving Right and Moving Left?
my axis
server will not know them
so your server event needs to know the final launch value
but its still wrong
do this
have your Dash Event return the final dash vector
then modify your Server Dash to call Launch Character with the passed in Dash vector
the value you place into launch character
like this?
ok i have another question... How i can do play UI animation after launching character
?
really?
yes
Say I have a login function in Game Instance to validate users - is it a bad idea to put the players load and save inventory in game instance as well?
Works fine for me
I have a blank character and replicated movement enabled. This is what my tick looks like:
This should rotate the character fully in 4 seconds
And it does, on the server
However, on clients, it takes exactly twice as long. 8 seconds for a full rotation
Why is that? The server is somehow messing with my client rotations, and I can't figure out how
(use controller rotation yaw is disabled)
Obviously, disabling replicate movement fixes it on clients. There must be some type of default replication functionality in replicate movement that is killing me
Hi! anyone know how i can play animation in function in multiplayer ?
With a seamless travel, do i have to copy the player state data manually ?
how do we use Epic Online Services with unreal engine 4
since there are no videos on it
I 'm asking you
@sudden lagoon Why are you asking me? I don't know..
I am asking every one in this server @split siren
You could ask in #epic-online-services but I don't think it's ready for general use just yet.
what's the proper way of replicating a character's controller rotation?
I'm doing a twinstick shooter game and I'm having trouble replicating the client's rotation because the Controller is null.
any tips? thanks!
@mild trout Controller exists only on owning client and server. ClientA cannot read ClientB controller
going to my list of things to remember about replication
so should I just do a regular Server call to change it's rotation?
RepNotify sounds like an alternative too...
Clients should never have access to each others controllers, so maybe putting a replicated "ControllerRotation" in your character class might be a way to go. But you probably have to give authority to client over that variable, but that is too advanced for me.
alright, will give it a try. thanks
running into kind of a specific problem with movement speed changes.
i have a "Stats Component" that handles any stat changes from buffs, including movement speed/gravity/jump height. Currently, I am only applying buffs to things on the server, and then replicating a struct representing them for UI display and cosmetic effects.
This prevents me from easily predicting movement speed changes. If I want to sprint, I'd need to tell the server to activate my Sprint ability, and while I can do client prediction of cosmetic stuff (speed lines, animation, etc.), my speed wouldn't actually change until the server activates the ability, applies the buff, the buff changes my speed stat, and the speed stat replicates down to the client who then adjusts the CMC's max walk speed variable.
I don't want to change the buffs/stats system as it works great for everything that I don't need to predict (damage/healing/etc. stats which are only used by the server)
but I also don't want stuff like sprinting to be unresponsive. On top of that, I do get a bit of jitter if the server sets the speed before the client since I'm not going through the CMC's custom move setup on the client first
hello..( Dedicated server ) How can i check player disconnection or if he quit application ?
I have database with Online Offline status of players...... but I dont know where to set player offline status.
Hello, I'm having issues replicating bone rotations, at the moment I've got a Blend space with my animations, then in my animation blueprint I got Transform(Modify)Bone to allow the player to reach out and grab items, my issue is that while the blend space animations are perfectly synced, I can't quite figure out how to sync the Transform(Modify)Bone across clients
Question on Performant ways to use FastArraySerializer:
What is a recommendable way to reduce the querying in order to find which item we want to modify?
My setup is the following: In my application, users will spawn (and can delete with undo/redo) actors over and over. They can select up to all of the selectable objects and then modify things like their transform etc. I was thinking I could store an integer inside the selectable items with their respective Array index, but that would mean that I would not be able to remove array items when objects get deleted. Given that users might create thousands of objects in a single session (undo/redo systems would find which index that id belonged in so it's only about new objects), I would prefer to not have 5k+ length arrays [and growing] after some session time.
If I don't do that however, it'd mean a lot of looping through to find their respective item. If I have 300 items selected, it'd mean looping through the array 300 times to find their respective item.
I could also do also do it by compartments (Say arrays of size 100) and then store inside said object which array chunk they exist in.
Any suggestions?
The "easier" thing to do is to replicate that transform at the Character/Pawn/Component level and ReplicateUsing (RepNotify). then, on OnRepNotifyTransform, you send the transform modification to your animation instance
Can you run a behavior tree on clients individually? For example an NPC in a game that everyone can talk to independently
the server usually does this
Can the server handle multiple clients interacting with the same AI simultaneously?
How can I disable character rotation replication whilst still using replicate movement ?
so.. no one got an answer to this ?
Why does this happen? I am wanting to create a reference to my custom player state BP on my player controller. Getting my playerstate fails on the begin play of my player controller as it has not yet replicated, which is fine. Instead, I'm trying to get my playerstate's begin play to notify my controller. I am validating it is not a server so that this code will only execute on the client version. I call an event on my player controller to let it know it's ready (the Player State Created event)
However, on my player controller, when attempting to get my player state, it still returns value of "None" and breaking subsequent calls to it, even though the event that triggered the call to get the playerstate was fired from the playerstate?
Here's what's in my player controller receiving the event and the foreach loop at the end is failing (ignore the other exec path coming up, it's not in use)
The one way I seem to be able to get around this is by doing something silly like this (which loops the invalid once)
Hey guys any idea why this doesn't work. If I have two horses, one enters the water then it's fine. When the second horse enters water, it appears the the physics volume stops working for the first horse.
hey guys - does any one have any videos or online resources that explain in detail on how to do a a game server build for linux?
@sinful tree I ended up doing similar because of all the race conditions like player state existing on server but not on client yet so i have timer loops to keep checking until it has everything it needs and count things up on server side by client notifying server. It is probably the wrong way but I havent found the right way yet. I hope whoever gives you the answer lets me know too.
@summer tide I dont know. Maybe setting water volume resets the physics or something each time? Why do you need to change it at runtime instead of just having the water always be a water volume?
@sinful tree @peak star at the point you're calling that the PS Actor was just constructed on client after replicating
the engine would proceed to resolve NetGUIDs immediately after that
the ideal way to do that is to use a bit of c++ and override the OnRep_PlayerState in the controller
(at the point where you're calling that your PC has a valid NetGUID for the PS, and PS exists, but the code to resolve the NetGUID into a reference hasn't executed yet)
Hey, how would you create a door, that per default is closed for each client. Then a client can open and pass it, but, for the other clients the door is still closed, and they can't pass it. I tried some approaches, like have collision enabled on client, but disabled on server and there just use a trigger to detect an overlap and then reset the clients position, but this looks bad. adding the involved actors to each other collision components to be ignored also doesn't work here.
Does anyone of you has an idea how to do that, aside from adding different Collision channels for this?
The first approach that works for me would be to create a second collision channel and add a trigger volume around the door and when the player enters the volume and a condition mets, I change the channel to this second channel and on leave I remove it. this way I just need one extra channel for all doors.
net pktlag=200 is not working for me anymore, is it changed? I was editing config files in order to simulate lag but saw this on answers, it was working before but not anymore with 4.26
I am trying to debug a movement replication system so on each change editing config files and restarting editor kills me
Actually even config files doesnt work...
[PacketSimulationSettings]
PktLag=200
PktLagVariance=0
PktLoss=0
PktOrder=0
PktDup=0
For "initial only" replicated variables, does a player joining the sever after the replicated actor already exists get an initial replication for that var?
Anyone got any tips for gracefully recovering from a lost connection? Don't care about reconnecting I just want to throw the user back to the main menu without the client freezing. Tried hooking SessionInterface OnSessionFailure and Engine OnNetworkFailure, the latter gets called but if I try to navigate away it just throws a fatal error
Edit: Answer was to use GameInstance's ReturnToMainMenu instead of my own logic, in both of those events.
i believe now its called NetEmulation.Pktlag
Thanks, should I include =?
NetEmulation.PktLag = 200
NetEmulation.PktLag 200
i think so
I see, still not applying lag, prorably I broke something else then. But at least I confirmed I was using wrong command. Thanks again
can one replicate TSet<> or TMap<> these days?
I don't believe TMap can be
When i travel from a map to another, i have to save/load players and game data manually ?
Hey, can anyone provide help, because I'm honestly out of ideas ...
I'm trying to work with an array of structs, but I can't seem to be able to save them, even though the values can be read properly ...
where is the array stored, is it a UPROPERTY?
@marble gazelle Can I PM you ?
Just formulate your stuff here . . .
This is what I'm doing
@marble gazelle Where the custom event is, the values get through as I want them to, but when I try reading it in the next line, only the host's values are read
You're telling the server to do something, and then a fraction of a fraction of a second later having the client try to read from it?
yeah, the array most likely wasn't replicated yet, but I don't see the call to your RPC, so
The replication isn't going to work that fast, specially in real life conditions. If you need to rely on data changed and replicated from the server, you need to use OnRep.
🤦♂️
Thanks guys
I checked what you said by just putting a 2 seconds delay right before the print
and it worked
Figures it'd be some tomfoolery in the background. Thanks for the advice.
ok! i've finally done, it, i've finally gave up on trying to make a door rotate and replicate to all clients by myself. can someone help me out with some questions regarding my specific situation?
I've looked at cedrics cheat sheet, i looked at videos that are pinned, but i'm still awfully confused! I've a feeling that something about my configuration I don't quite understand well between replicating Actors using an Actor Component and one mesh that moves, with PlayerController input split to 2: interaction button and axis mapping to move the door "smoothly"
My attempt was fairly straight forward when i've set it up:
DOORimplementsI_Interactableinterface (to interact with it)DOORhasAC_Dooractor component (lets you calculate rotation and player facing direction)PlayerControlleronInteractinput, interfaces withI_Interactableby Custom event that isRun on serverwith the event ofInteract(which then locks only the Looking behaviour i.e. locking the perspective to face the door and using the axis to move the door)
4.PlayerControlleronRotateObjectX/Yinput interfaces withI_Interactableby Custom event that isRun on serverwith the event ofAxisInputDoorhasDoorRotationRotator, which is replicated.
6.Doorhas the actualDoor Meshset to be component replicatedDoorset up to be replicated in class defaults.DoorImplements both of the interfaces fromI_Interactableto calculate the door changes and disable looking axis on the player controller
with all of the above - the following happens:
- Server moves door, it is replicated to all clients and server
- Client moves door - nothing happens, doesn't event move the door on the client
so #2 is the problem. and I'm guessing that the client does not have the authority to send an RPC to run on server, but debugging it, it seems like it does send the RPC correctly. So I'm even more confused. why is the DoorRotation variable on the Door not being replicated then?!
Interestingly if i make the events not run on server, the client can open the Door, but its not replicated on the server
but that makes sense
So my real question, is, how do i make my client to have the ability to signal the server - "Hey! I want to open this door! here are the inputs!"
I think possibly you want to set your DoorRotation as an OnRep variable, then on the OnRep function, set your rotation on the door.
I tried it as well @sinful tree , unfortunately that didn't work - same effect as before - calling it from the client would do nothing to the door - calling it from server replicates to all clients
Putting a breakpoint for the interaction on the Actor Component, it seems like when the Client is told to Replicate on Server - it does not do so.
I think i need to understand better client ownership. because I feel like I'm interacting with an actor that is not owned by the client - but the question is - should it be owned by the client? If it is, how do i set the ownership temporarily to one client dynamically? and then release it to be the server's?
Client must send RPC to server to request the server opens it. Server opens it and it replicates to all clients.
And if it shouldn't be, how do I go about sending events to the server about this actor with my input?
Yeah, I've set it up that way, client asks to interact with actor "X" -> that interaction is setup as a custom event that is set to Run on server
I feel like i'm missing something 😦
If you toggle it on the server does it replicate to clients?
Client can only send RPC to server if it is the owner (I think)
Try putting the RPC on the player controller
the rpc is on the player controller
Erm I don't know sorry. Maybe some BP specific issue? I only use cpp.
i'm still convinced it's about the ownership of the client like you mentioned before
since the Actor is not owned by the client - then the server will not receive this event
is there some function you use in C++ where you set an ownership to an actor temporarily? have you ever encountered that?
Player controller will always be owned by the client
I figured it out, after days working on this thing - i finally figured it out
OMG
So when you build a custom event, to make the interaction from client -> server. I had to pass the focused object as you see in my blueprint above.
The thing that was not trivial for me to understand is that since it already runs on the server Focused Object does not exist! It's None. So basically the interaction is being sent on the server but fails silently because it interacts withNone!
The way i fixed it was to change the Custom event that runs on server to have Focused Object sent with it instead of trying to get it from the Player Controller at the time of interaction on the server.
Is there a better way of doing swimming than this? https://gyazo.com/066331e4d27d8600c070eeda3388cdda
You don't need the IsValid checks as the Cast nodes basically ensure that already.
You probably don't need the Do Onces there either. If you're in a volume and you overlap with another you'd have no change. If you exit the volume then you'd be doing the end overlap function call already.
Without do once, caused issue. By the way how many physics volume I need to place in the level for multiplayer.
If I put one, when the second player jumps in the physics vol leaves from the first player
Currently it works in offline mode, if I play as a client, when I try to jump into the water, before it overlaps the char the char goes into falling anim and stays floating above water. Maybe It's not replcating properly.
@sinful tree Any idea issue replicating this?
@summer tide it is a strange thing. Volumes are part of the level. The level should be the same on all devices. If it is water for one device it should be water for all of them as long as you do not tell it to stop being water.
Well after looking a bit more at it, it looks like you're changing your character's physics volume to water. You should probably create a physics volume created in your scene that's in the place and the size of where you want water to exist. No need to change movement mode or variables in your character's movement component.
Only thing is you have that mounted check - not sure how you'd work around that.
anyone know a reliable and accurate way to sync server and client time sub second (millisecond). For a count down timer.
@sinful tree So I have river and lakes which makes it impossible to place physics volumes all over the places. I wonder if the new water includes the physics volume with the spline.
teag
I don't see why we would want widgets on dedicated server
yeah, I'll just turn it off 🙂
wonders if there will be fallout 😄
It's probably because they know some people are... not great at engineering... and put actual game logic into widgets. Having server builds include widgets by default at least gives them an easier time than stuff randomly not working, and anyone who knows better will find that option and turn it off.
Hi all, I want to repNotify a structure, which contains vectors and replicated actors/components references. I properly receive the vectors, but no reference. Has someone an idea ?
Print before : https://cdn.discordapp.com/attachments/779005305408192543/797910620153315328/unknown.png
Print afer : https://cdn.discordapp.com/attachments/779005305408192543/797910635739873300/unknown.png
logs (bottom to top) : https://cdn.discordapp.com/attachments/779005305408192543/797912469603352606/unknown.png
@manic cypress reference get replicated in the multiplayer framework, the server is in charge of reference ids
you can get a local reference, and should be matched with the server if the reference/actor gets replicated
Anyone have experience with the Oculus OnlineSubsystem? I can't seem to check if my requestdelegate is already active, causing crashes in the editor every second time I test the game
Needed to check if OSS was initialized every time and throw the function into an if statement
exactly every 2nd time?
and in the editor, wouldn't it be using the null oss anyway?
yeah it was every 2nd time. The OSS was initialized every time play was hit, then when the play editor was closed OSS->Shutdown(); was called. When testing the game again OSS was not initialized and needed to be called manually with OSS->Init();
hi all, noob question. what is the correct way to create a client-side object that will persist between game sessions w/ a server? AFAIK this will load a new "map" and clean up most of what is on the client.
for example, to persist a session token with the platform across multiple games
Extend UGameInstance in either C++ or Blueprint and then set it in your project settings
It will be created when your game starts and won't be destroyed until your game ends, and is accessible from pretty much everywhere. Loading a new level won't destroy or recreate it, so you can put data you'd like to persist there.
If you're using c++ you can alternatively make a game instance subsystem which has the same lifetime as the game instance, but lets you organize things a bit better by separating it into a separate class. https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Subsystems/index.html
An overview of programming subsystems in Unreal Engine 4.
game instance, perfect. thank you!
are RPCs always required to be void? or can they return data?
only makes sense for a reliable RPC of course...
RPCs cannot have return values.
You can, however, have one RPC call another to give a result back
makes sense
I have a component im writing that has a few variables that aren't always needed for every child class, but they need to be replicated when they are needed. Is there a way to negate the perf cost of having a bunch of unused replicated variables on the component? Like a way to disable those properties replication on certain child classes?
@distant talon Hmm. Maybe. I do something similar with an inventory component. Are you using C++?
Yeah, this is a c++ component though i might want to make bp children later
What I do, is make the parent component do an if statement inside of GetLifetimeReplicatedProps and use a bool to switch how the parent class sets up the replication of properties. For example, I don't need a player's inventory component to replicate to anyone but the owning client since in my project no one else needs to see the player's inventory. But I use the same component basically on a lot of other objects that everyone does need to see. So I use the bool to determine whether to set the replication to OwnerOnly or normal replication, and in the child class, I just change that boolean. Could probably get away with the same thing to disable some replicated properties in child classes.
I haven't tried disabling, just changing how it's replicated, but I imagine that the same philosophy should work.
huh, handy to know, i do have some bools i can switch with inside GetLifetimeReplicatedProps. Do you happen to know offhand when that func gets called, is it just once after/before beginplay or on a continuous basis?
I'm not exactly certain, I've never tracked down the call, but I assume that it's some time near the object constructor. I remember having to create a child class to change the bool for some reason. But it's definitely only one time and long before beginplay.
thanks!
@distant talon It's called on the Class-Default Object, so as long as the properties are set at the class level it will work.
I.e, you can't set those flags on an actor component of an actor blueprint for example.
You'd have to create a subclass of the component with the properties changed, then use that component.
If you want to enable/disable property replication at runtime you can override PreReplication
base actor class does this for some properties so you can see that for an example
Huh, nice. I will also take a look at PreReplication
Someone has any resource on seamless travel and data persistence (BP) ?
multi-cast delegates operate the same way as functions - i.e. ownership ?
GameState fires a delegate, but my client (HUD) is the one listening out for it. That won't work, will it?
My fellow multiplayer gurus, i come to you in times of great need.
I'm quite new to networking and im trying to do a very basic first game, more like a test really.
My issue with how do I differentiate between the two players/clients?
I have a very basic set up, just a player controller placing marks/symbols on the screen.
The idea is that the other player needs to place their marks on top.
Right now i have ZERO idea how do I differentiate between the two players/their marks?
Even something as basic as each player having their own colored marks, right now the replication is working but i have no way of understanding what player places which mark.
Depends really, you could assign each "mark" with a Player State for example
Using the Player State is the key way to differentiate between different players on a Client machine
oh thank god i think this is what im looking for, player state
How do I go by assigning them a player state? ill google it too of course but as i have you gurus here
🙏 🌞
Players already have the player state, you just need to extent that class with your functionality
Yeah, it really depends what your "Mark" is exactly. You just need a way to assign a player state to it
If you had an actor for example, you might spawn it and assign an "Owning Player State" variable (Server-Side)
Players then know who "owns" what
Mark is just a BP with an actor in.
Where should I do my player state business? In the Game mode event graph or the mark BP itself?
that sounds exactly what i want
Hello guys, please does anyone know a good plugin/project on the marketplace or anywhere else for a dynamic gravity system that has multiplayer support?
Thanks
In this situation I don't need to run "New Round" On server, or Multicast because of Switch Authority Correct?
I'm asking because I am not sure if I properly understand when to use switch authority vs Multicast
I could probably achieve this same effect by just using a rep notify to determines the amount of zombies, but rep notify is hard
@twin juniper Gamestate is where I'd do all that. I would start with an enum (Planning and Action)
Where should I store things like Health, Stamina, equipment, etc, if I were to create a multiplayer game with a dedicated server? The GameMode blueprint? From what I've understood, the "GameMode" is the only actor that is server controlled, which means that players cannot cheat if things are happening there. Does that also mean that all calculations like damage should occur in there as well? And then sent to the GameState to replicate it to every client?
Those variables should live on a component on the character or whatever the player's Pawn is
I would say on the PlayerState. And I'd also add : GameplayAttributes might be what you are looking for, there are tutorials explaining how to use it and where you should put these
It really all depends. If health and stamina an equipment are also things on other entities in the world like doors and enemies and treasure chests, then just build a system in whichever way is most consistent.
If someone is asking if health should be on the game mode, they definitely shouldn't be messing with GAS lol
Aren't most actors server controlled? In a multiplayer world you'll want most of your actors created by the server then replicated on relevant clients which makes the server authority/owner of these actors. Up to you to make RPCs and variables that are only updated from their owner (server) then replicated to relevant clients.
I'm a newbie so don't take my words for granted
I'm just trying to wrap my head around all of this 😄
It would be a nightmare scenario for me to build everything then realize that I did it wrong and then have to do it all over again, hehe
When in doubt, use rep notify to do things.
So, is it not important "where", as in, in which blueprint/actor variables are stored? And is it okay to "spawn" and actor of the "actor" class to make line traces and then perhaps "launch a projectile"? etc
Start with reading this.
Data/Function locality is much more important in multiplayer
In SP you can get away with any crazy setup
In MP you need to think more about what data/functionality is relevant to what
It all depends on how your project is architectured, but I like to have healthy on the pawn itself. Typically inside of some sort of component, either a health component or stats component
So variables can be stored anywhere? Should I not worry if I have stored things on the pawns themselves?
Using league of legends as an example, the player state would hold character level, summoner spells, last hit, kda, etc.
The pawn itself would have health, armor, ad, ap, etc.
But where would NPC's store their level, health, etc?
For me this video helped a lot https://www.youtube.com/watch?v=KsORRtBOJYc to clear things up. Series of 4 videos about networking, explanations are great and followed by examples 🙂
📹 Part 4 of our replication series unlocks limitless potential with Multicast and RepNotify! In this video, we dive deeper about how Unreal Engine's Actor Replication really works as well as introduce ourselves to a variable replication and how combining the power of variable replication with an event driven design can help us build a multiplaye...
The NPCs will be pawns as well.
So NPC's have their own Player State?
No, that's why you don't put health on the player state
I'll watch this in a sec 😉
Well this one was on me sorry
By the way, I've been playing with GAS recently for a multiplayer RPG project and I have this question I can't get off my head: why should I replicate every Attribute? It's really network consuming so why not only load attributes when the actor becomes relevant (Net Load), then reliably replicate ONLY movement and abilities (the enum ID) ? -> each client computes damage and update health bar and attributes locally -> attributes won't be directly synced but they should still have the same values as server right?
What would go wrong? Is it about the risk of desync?
And if a player cheats attributes locally, well... it just screws its own instance, server won't be affected
Since I don't know of tutorials / projects that do things this way, I guess other actors attributes would end up desyncing from server at some point or something, but I cant seem to find out what could go wrong
Also, do you have any resource about how packets are handled? I mean a place I could find out which/how packets are merged before they are sent (same priority, by reliability status etc) I guess it's not 1 RepNotify = 1 UDP packet
Alright I watched the video. So from what I have gathered, it doesn't really matter where variables are stored and how things are calculated and spawned, etc, as long as it's properly replicated and given the server authority when needed?
@dull flare Once you have both latency and any sort of client authority you will have desync, it's a matter of how much and how you handle it. In general I've found that Unreal's solution to this is to try to do as little client prediction as possible, only doing client prediction where it makes the very biggest difference to how things feel (like my pawn's movement & UI input) and trying not to get in the business of predicting other stuff where latency might be acceptable, such as attribute values.
There are plenty of games out there that use different approaches, but it's probably easiest to do things the "Unreal way" if you're using their systems, otherwise you'll be fighting against your tools.
@lunar sluice well as Jambax said it actually matters, and I guess your choice should be driven by how you want the actor to be replicated to clients. And the behavior you expect is not to "give" the server authority: the server just has the authority if he spawned the actor (dunno if the difference makes sense).
Hi, are there any caveats when replicating arrays?
and what about array of structs?
I'm quite a noob in networking
and the client sees 0 as the Tiles amount
Sure that makes sense. I guess I'm just a bit confused as to what I'm supposed to do with "GameMode" and "GameState", or if I don't have to use them at all if I do thing differently
Game state is replicated to all clients, game mode only exists on the server. The game mode defines what pawn you have, where you are spawned, many other things. you can put logic in the game state but often the game state is written to by the game mode.
Nevermind, changed a function to Server
To know what pawn the player should have, would the GameMode not have to save all of the relevant variables to create that character? Lets use an MMO as an example. Shouldn't the GameMode have the information about the player that is logging in to the game then? Everything from Race, Gender, Items, Stats, last location before logging out etc?
Yes, in that context it would do all that stuff because the game mode is what hands the character to the player controller.
It would probably fill out the player state and then spawn the character for the player.
Hmm, alright. Thanks for the help guys 🙂
Good luck. Don't make an mmo.
did anyone ever network physics sounds?
@thin stratus solved my issue - thanks for your support
your Networking Compendium was a great help finally
Ah
why IsNetRelevantFor is constant? :(
https://gyazo.com/ea85c34b7efb79efb8ae0ca05ebfdaed I would like to do stuff like reduce polling rate for distant sectors. Guess I need the rep graph for that, right?
IsNetRelevant will be called everytime that actor is considered for update
Server needs to see if its supposed to be relevant or not for that viewer
i mean repgraph will help
cause it splits the level into a spatial grid
and you can pull actors only inside tiles that are relevant for you
that was one of the main reasons they made repgraph
so they didnt have to ask every actor if they are relevant for that player
well I have relevancy sorted already
that's done
however I would like to reduce the netupdatefrequency for the distant actors
yeah repgraph wont call IsNetReleavantFor
if you use that
you would need RepGraph and a special node
to handle it
oh okay, so the netupdatefrequency stuff needs to be done in the repgraph yes or yes
well it still uses the netupdate frequency
but it wont do IsNetRelevantFor
and it will only show actors that is in your area
iirc
I don't know if you are understanding me completely, but relevancy is sorted, I only want to reduce the net update frequency of the distant relevant actors
thresholded by certain distance
yeah but how can you do that? how will the server know that those actors are far behind and dynamically reduce it. You could possibly do it with some engine changes, but you can't go modifying the actors, so it would have to be done on a per connection basis
is your IsNetRelevantFor expensive to run then?
not much
it's reasonable
but within the same iteration space
I could grab the viewtarget and set a minor update frequency
however I can't as its constant
yes but say you modify B's instance, A is close to B and C is far away, if you modify B's update rate, then A would see updates less cause C is far away and reduced its update rate
Oh my god, how didn't I think about that?.... lmao
so... isn't there any method to change the update frequency a local player gets from a simulated proxy?
why u want to reduce NetUpdate based on distance ?
maybe GetNetPriority is what u r looking
I don't want to change the netupdatefrequency now that kaos bonked my head
I do want to change the update frequency a local player gets from a simulated proxy
i'm looking at client perception to reduce the amount of bandwidth that gets sent to a specific client
so... imagine netupdatefrequency would be contextual to a pair of clients
I do want something like that
u can send compressed data to decrease the precision its like reducing NetUpdateFreq, for instance sending the Yaw as a byte instead of a float
trying to run a ue4 dedicated linux server on aws but the logs from the server seem to stop after "LogNetCore: DDoS detection status: detection enabled: 0 analytics enabled: 0" print out and the server doesn't load into the server map but the server loads fulling when I run on my local machine "LogInit: BSD IPv4/6: Socket queue. Rx: 262144 (config 131072) Tx: 262144 (config 131072)" should be the next log output so it could be hanging on this step any idea what the cause is?
realistically speaking I would need to filter by pairs to do that, trying to look for a more generic solution, probably integrated within the isrelevantfor iteration space
ie: significance manager
I saw the convo about testing. @chilly mason if you're around, can I ask did you ever do multiplayer testing via Gauntlet?
yes, but probably not the way you'd think
I experimented with Gauntlet, but I dont have source build so I was trying to use the built in Gauntlet DefaultTest class. This allows me to launch a server and some clients, but no obvious way of passing arguments into the clients/server.
I have written some Functional Tests (launched via -ExecCmsd="Automation RunTests Blah" ) but cannot figure out how to tie the two systems together. How do I launch stuff from Gauntlet and execute the tests on the instances?
my game's multiplayer is not based on the ue4 client/server model
ah yeah you have the lockstep deterministic setup
correct
running unreal tests still seems to involve invoking the Dark Arts
you can just call different tests that all have their own parameters can't you?
via -test=YourTest
hmm perhaps... and pass it via Gauntlet by using -clientargs="-test=YourTest"
I think I need to restructure my code a bit - at the moment when I run a test it loads into the FrontEnd, executes a bunch of code, then after a few seconds starts running the tests (which load other maps etc).
Feel like I need to somehow make it skip the default map...
-test=MyTest does not seem to trigger anything on my Game exe
in fact, can the Unreal tests even be run on a Game build? I usually run them via UE4Editor-Cmd.exe
they can even run in a shipping build
cd c:\Work\UE4Source_425\Engine\Build\BatchFiles
call RunUAT.bat RunUnreal -project=Horu -platform=Win64 -configuration=Shipping -test=LargeFleetTest -build=c:\Work\HoruTest\PACKAGED -uploaddir=c:\Work\Horu\Horu\PerfTests
yeah so that's the Gauntlet cmd line - and you have a C# class called LargeTestFleet right, but what does your gauntlet job pass into the clients on cmd line to run tests on the actual instance?
