If you only need ListenServers to respond then ClientServersOnly is fine. The time it takes for Clients is more or less a faked duration. It just asked every PC in the LAN via Broadcast IP if they are hosting and it waits a bit for a response. Online sessions would either way take a bit of time due to having to send a package to the masterserver and receiving an answer.
#multiplayer
1 messages · Page 66 of 1
ahh, I see..
by any chance you know of some good Forums / Tutorials for movement in C++
I already said the pinned messages have something
okay okay, my bad
sorry passed out lol I swear I seen that option but I'm not finding it Actor > Skeletal Mesh Comp > ? or skeletal mesh > ?
Found It: VisibilityBasedAnimTickOption
What would be the opposite of that? for the future. If the thing is left alone wouldn't the tick need to 'refresh' to where it should be?
But I have all that all set already with repNotifiy and setting the anim position to where it should be.
then just ask
- You aren't playing any Montage.
- Unless this is a different language, the word is spelled "Death" for the function as well as "bIsDead" for the variable.
- StopMovementImmediately only sets the Velocity (and maybe some other stuff) to Zero, so you need to also stop the Behavior Tree.
- You should utilize the Boolean you created to block the Damage function from calling your Death event more than once. Or probably best to simply check the boolean at the start of the Death function.
oh sry ok
Also you should probably check if the health is <= zero AFTER it takes damage, not before.
(Also 'health')
"simply check the boolean at the start of the Death function"
🙂
Is it permitted to discuss methods for anti-cheat here? I know discord TOS prevents servers from allowing some topics, many of which revolve around cheating or hacking in games. Obviously, any discussion should be limited to not divulge information which could be directly used by someone trying to cheat or hack... but can we discuss methods for preventing things? Or even just discuss the scope of vulnerabilities in certain implementations?
I wouldn't see why not at this point
is the oss updatesession call broken for anyone else in v5.1? mines makes sessions disappear. client can find the session when created, but when updated using the exact same settings the client can no longer find the session. i think epic broke updating sessions.
The fact that you're asking here, means you probably don't want to bother with anti-cheat. The only games that should have it are competitive AAA titles, and if you were working on one of those you probably wouldn't be asking here.
Very crass over-generalization. Don't put me up on the Via Appia 😂
Might also depend on the Subsystem you use
you're not wrong lol. but I am curious and want to learn!
Anyone know of good notes/documentation for getting playfab setup in ue5?
Microsoft has a quickstart for it, is it not good?
No.
You'd think given that service is shit ton expensive
When you're doing a hard/absolute travel to a new server for the first time, how on earth can you stop the client from flashing some weird view from 0,0,0 for a split second
I can't even figure out a way to cover it up with a loading screen or something, I guess I don't understand what the client is actually seeing at that point. It seems like they are able to see the level before their PlayerController even fires BeginPlay.
For instance, I thought I'd fade out from my main menu to black, and then fade in after client has connected to server. But I can't figure out somewhere early enough on the client side to hook in and the black screen / fade in starts too late
There's no delay I'm aware of for the GameMode spawning the client, and I have "Start players as spectators" off
So, multiple things. 0,0,0 is indeed the player watching the world from the PlayerController's position. The Client also has a fake PlayerController locally until the actual one replicates, so there is a time in which it kinda hangs in between everything.
What you can do to cover this up is to implement your own CameraManager
PlayerCameraManager that is
And to handle the case where the PlayerController has no Character as ViewTarget
by e.g. showing some global camera that shows the map
If you don't have such a camera and you just want to hide it then showing a proper Loadingscreen that you only remove once the player has a local character possessed would be an option
Thanks I'm glad I'm not crazy 😄 I've had a difficult time trying to figure out what was going on but I figured there must be something like the temp/fake PlayerController. I will look into the PlayerCameraManager (I know there are Camera Fade options also)
How would you suggest go about the latter- triggering a loading screen from the very first moment that temp/fake PlayerController is active though? I guess what class am I sticking this code in to start would be super helpful
I usually trigger Loading Screens when leaving the prev level
Is there a class for this or something though that doesn't get destroyed on a hard travel? I've tried adding a full screen widget (fading to black) when leaving main menu and it must just get wiped out on the transition when opening connection to server
There's not a dedicated class for loading screens I'm ignorant of is there? Thanks again
its steam oss
Gotta be honest with you here, I never tried to do this in Blueprints
idk if its because i'm using universal dev app id 480
All loading screens I added were done via GameInstance, binding to PreLoadMap or whatever it is called and using the Movie Player module that has a Slate Widget param.
Hm, no, but UE does have bugs with Steam OSS atm. Not sure if this is part of it but I read that people aren't able to host and/or join and there is an active issue about that. Maybe it affects more
riparoonie. thnx for response!
That’s cool. Didn’t realize GameInstance had bindings for that. Figured it might be the spot to be since I’m already using it to persist some data. Thanks again!!
GameInstance doesn't have bindings for it, but GI survives the travel so you can bind to those delegates on init
Think they are FCoreDelegates or so
Also I don't know if there is something better by now
Stuff like this sometimes silently improves
This could potentially fit in #cpp so let me know and I can move there,
I'm currently looking at replicating an array and being able to see what objects were added/removed since the last rep
Header
UFUNCTION()
void OnRep_ActionSets(TArray<ULyraExperienceActionSet*> oldActionSets);
UPROPERTY(ReplicatedUsing=OnRep_ActionSets)
TArray<ULyraExperienceActionSet*> ActionSets;
Cpp
void UActionSetManagerComponent::OnRep_ActionSets(TArray<ULyraExperienceActionSet*> oldActionSets)
{
// What is the best method to compare two arrays to figure out what objects were added/removed?
}
I can just do multiple for loops to check if one array contains the objects in the other and get a list semi-well that way, but I'm not sure if there are better methods or if I should take a different approach overall
To give some context. The server can request to load ActionSets (list of Game Feature Actions), which need to be replicated to the clients and get loaded
@tender gale Look into Fast Arrays, they have convenience functions for just this issue.
Second link is probably more digestible.
Oh perfect! I’ll take a look at it now thanks
Can it hold object pointers as well, or just structs?
They can hold anything, they are like a regular Vector. However they only support replication for POD and Unreal types (UObjects, UStructs, etc etc).
Just to be clear, for UObjects, that same Object must exist on the Client and it be "Net Addressable" for the pointer to be appropriately resolved on the Client.
If you have a bunch of predefined (via an asset container somewhere) things that you want Clients to receive from the Server, instead of trying to address them in a dynamic way, you could instead tell the Client in which asset to find them (since the Server and Client would both have the container asset) and pass along an identifier for which one to use, performing a lookup on that asset.
As a heads up, replicating pointers only works if the object is replicated between client & server. BUT it also works with on disk objects so if your pointing to a data asset then it's gonna replicate because it's on disk at the same locations
Hi, can i replicated variables in Widgets? Or better put this variables to Actor Components and then use Rep Notify to update in Widgets?
Widgets are not replicated, so yeah you would use a component or external object to talk to the widget. But usually the widget should just be listening for this stuff via event dispatchers
I use set timer by event, an if i put variables in actor component then I need create many Set Timers by events
Thanks for the heads up. Yeah in this case they’re pointers to data assets so it should be fine
I have this widget 20x
Sounds like you may need to rearchitect that system if your having a bunch of timers to update stuff, but that's dependent on what your trying to do as the end result
Users can add many widgets from array in Actor Component, and in widget are Cooldown (float variables) and there is Timer what have connected Cooldown to Time. Cooldown variable must be replicated. Sorry for English 😁
Does anyone have a hint how I can solve this without creating multiple Timers in Actor Component
Ah gotcha, thought you were forcibly updating the replicated variable with timers. Yeah that's totally fine honestly if it's like 20 timers
You could do the timer route or have a management component that handles the replication for all of the start times and just calculates the difference every tick, and if it exceeds a certain amount then remove that value(signalling that timer ended)
So when I set this variable what is in Widget to replicated, then Wil be OK?
So then you'll only have one component ticking but it's still updating the widgets
When it is set with a rep notify or something, you would tell the widget or use a delegate to have the widget update based on that
So, Timer will be still in Widget, and I create reference to Component in this widget and get variable
Yes? 😅
No, I wouldn't even put the timer in the widget. General practice with UI is to have it be REACTIVE, and not driving gameplay features
Because UI goes through LOTS of iteration it's easier to decouple that functionality
I guess I don't understand it a bit, from what I know, I would have to create a separate Timer for each widget
- Create an actor component, this will have the timer and the replicated variables
- When the replicated variable changes and you need to update the widget, have the actor component TELL the widget it's new value to use
- Timer completes on the actor component and tells the widget to update based on that.
Yes you will have a timer for each widget, your getting hung up on that which is not proven to be a bottleneck
A bit of a poor solution if you want to have 20+ of these widgets 😥
In what way?
To many Set Timer by Event in one component
And not automatic
Your confusing it like there is one component handling ALL of the widgets
You would put one component to handle the replication and the timer for one widget.
The optimized way is to use one management component to handle the replication and would not use timers and instead tick and update those values for all the widgets(I have already said how to do this btw)
So for each actor that you want to have this automatic replicate with, you would add the component(which handle creating the widget for that actor and it's corresponding timer). At this point I have repeated the same thing multiple different ways
Wait, but each widget has different cooldown
Different cool down time? If so you can just set that on the component and it will propagate to the widget
So I need create component for each widget?
This is something new for me, sorry if I don't understand 😅
@half umbraI think it's worth asking. What is this widget for? Why does it need a cooldown timer?
In the multiplayer programming quick start (https://docs.unrealengine.com/5.0/en-US/multiplayer-programming-quick-start-for-unreal-engine/), the collision delegation AddDynamic for a projectile is wrapped around a check for GetLocalRole() == ROLE_Authority, is there any reason why we do this instead of just using AddUniqueDynamic besides not giving other characters the authority to add delegates? just curious as to whether there's a major multiplayer principle behind this
I have skills that the player can use, I have created 1 Widget that is created for each skill from the Array and for each of these skills I need to have a set cooldown that needs to be replicated
There is a core fundamental to UI practice. UI is meant to display gameplay state and enable input into gameplay state.
Putting a cooldown timer on a widget is storing gameplay state on the UI, not the gameplay object. Your widget should simply by given a pointer to the skill or to the component that has the skill with a tag or some way to look up the skill.
The widget itself should tick, and update itself based on what it can read from that skill or component.
The component itself or the skill itself should have a cooldown set up somehow. I personally prefer just storing a single float at use of the current game time and letting other functions look that up to determine cooldown and whether the ability can be used. Timers are harder to work with for savegame stuff and also cost tick time to update something that can just be a written state.
Can you send some example?
I can't do it without Set Timer by Event
What's wrong with setting the replicated Float (Cooldown) variable once in the component and getting that value in the Widget where is also used Timer?
Ok timer in widget is bad, right
Now, I don't really know how to do it properly, I rather know that I can create a separate Timer and variable (repnotify) for each skill and call functions to update the value that is in the widget
Scroll up, I already explained this to Scer2, about UI being reactive. Mainly wanna save you time repeating stuff 🙂
But how to make it so that there is only 1 Timer that supports many skills is no longer possible, you can create a Timer Handle (Array) variable for the Timer, but this Timer will only tick for one widget anyway
You can have cool down be a derived number based on time of last use or time of next availability
You don't need to replicate a number ticking down
Unless you intend skill cooldowns to be chunky and not smooth
Without a visual example in BP, I will not understand it, I am a visual person. The skill has a timer that shows the time left, it must be updated as long as the timer is active
What do you intend to see visually, something smoothly updating like WoW?
What do you think about this?
I know, but if will be False then will be updating widget Counter progress bar etc, if cooldown Array will be empty then will stop ticking
i need change smooth progress bar or something
Then throw that timer out and use tick. This is in the UI right?
nope, this is in component
Why do you have an array of cooldowns? You doing some SOA type thing?
this is example, instead of Cooldown array will structure array, where i have many other things what are should replicated
If you have any good suggestions, please write, i like learn
ok, no, i take it back, must be a single variable
When I launch a dedicated server, is there a node I can find in blueprint to find dedicated servers that are currently running, like you can with sessions?
Is there a way to get a list of relevant players for an actor?
You'd make the dedicated server start a session when it starts up.
Since a dedi doesn't have graphics/animations, how can I reliably get the position a weapon in a player's hand at the time it fires? I can't trust the clients, because clients lie and could fire in any direction they want.
Essentially the issue I'm having is firing a projectile from a weapon is going straight into the ground, because the mesh isn't animating on the server, AKA it isn't pointing forward.
Tick mesh on server. Settings on the skelmesh
You aren't guaranteed to have the same as clients tho
Think I found it; GetMesh()->VisibilityBasedAnimTickOption... Thank you, giving it a ...shot.
It works, fault was on my stupidity. I was getting some client/server functions mixed up, and the server version was never being invoked. The VisibilityBasedAnimTickOption worked.
Im on my first project. Is it easier to use root motion or no root motion for a multiplayer game?
Depends on the game but it'll be hard no matter what
What's the gameplay?
rpg survival sort of game
got all my inventory and equipping items working nice. now to start with animations and making attacks etc xD
Depends on the style I guess, but I usually recommend a mixture of it. RootMotion for Attacks and one time AnimMontage should be fine and the CMC takes care of them as good as possible.
But for the AnimBP I usually use normal anims and let the CMC handle movement naturally.
If you need start/stop Anim behavior etc. You can have a look at what Paragon did in the past. Lots of that stuff is now simpler to setup in ue5
Does anyone have experience networking Collision Meshes for movement? Is that viable or is it standard to just use multiple primitive components to approximate a Static mesh shape for a vehicle (Plane Tank etc). I'm curious how AAA do it; If you add a moving vehicle with a different mesh shape, if you don't use a collision mesh then you'd have to do a custom set of primitive colliders to best fit then shape and re net code it again?
I think but not sure are collision meshes designed for networking or are they tied only for physics engine to simulate rigid body collision which is a nightmare in networking (Indeterministic). Otherwise for networking the only way is to use a set of primitives with the physics engine to sweep ahead of movement for collision or overlaps then handle/resolve movement in a deterministic way (Slide against wall etc..).
It's not a networking thing. Anything moving should usually have convex hull collision to help resolve intersections correctly.
Convex hull might be too expensive and I am unsure how good sweeping or if sweeping is even possible with a convex hull. If sweeping does I am curious how to handle Movement Resolution to be net coded later on? So the other option is to wrap the mesh with simple primitives (Capsule, Box sphere etc) Sweep them all together and use some kind of dead reckoning to sweep ahead of movement and then handle the collision resolution and net code it that way.
This is why I am a bit curious if anyone has had experience doing custom tight colliders for different shapes and net coding the movement for it.
Yeah I mean that's a hugely complicated topic, and usually very game specific. Racing games, flight sim, arcade, simulation, all decide what you want your priorities to be.
If you want a general resource to read up on, gaffer on games has you covered.
I remember there is a learning example talking about bulb switch, loot box in multiplayer, I just can't find it, if you know it, please tell me?
I set number of players to 3 with net mode "play as listen server", and two are playing niagara but one is not. do you know why?
Unreal physics allows welding of primitive colliders to get collision resolution done for you, with a little C++ work I think its possible to sync the physics and game thread results to replicate it in a deterministic and perform proper network prediction. That Ideally is a good solution if you wanna just weld primitives and let the engine handle the resolution for you. I might try that later down the road.
@kindred widget Thank you for the response, I sort of had a guess that nobody could really help me as I have provided way to limited information for such a large topic. I guess learning about the development tools available would be very helpful, as I can measure the data and basically work with that.
Thank you very much! I have seen and know about both performance profiling and also the replication systems, but haven't seen the sever optimizations! Thanks for the links! I really appreciate it! 🙂
hello, this is a actor and in take damage, i simply put if health is less than zero, destroy .. it's working fine in server and standalone but in client, it wont destroy or it is getting destroyed i presume ( as i can pass through the actor - no collision) but mesh remains in level .. what can i do ? thanks for answers
You need to ensure that the damage stuff is called only on the server and that the wall is replicated
thank you for the suggestion ..
Here's some resources for anyone wanting to do this
https://michaeljcole.github.io/wiki.unrealengine.com/Loading_Screen/
https://nerivec.github.io/old-ue4-wiki/pages/global-fade-in-out.html
Was able to get the effect I wanted pretty easily using that fade setup and the bindings on GameInstance. Triggering the fade-out is actually done from PlayerController with a matching delay before calling Open level since PreLoadMap wasn't occuring early enough
A static site pulled from the internet archive
I admire your optimism and wish you the best of luck!
But please don't think of it as a 'little work' it's a huge huge task and the details of how you handle latency and collision conflicts is where the devil lies. Your game design needs to embrace the limitations.
All depends on your game and desired user experience of course. This is a good talk into the networked physics of Rocket League: https://www.youtube.com/watch?v=ueEmiDM94IE
is there a way to open source code project in the standalone editor without conversion etc. ? I am looking for a better way to collaborate with artists in our Multiplayer / dedicated server setup - so they dont need to download the whole source and compile etc.
Not really a multiplayer question - you'd be better off in either #engine-source or maybe #source-control
but I think there is a way in which you can 'hack' it to force it to allow loading assets created in different versions, but really it's much better to have everyone on the same version. This can be done via Installed build, UGS or building the editor on each machine.
Thanks for pointing in the right direction, will have a look into both ugs and installed builds
I want to load different map when I launch game as a server and client, how can I achieve this?
just wanted to bump this, hope that's fine :)
Anyone here recommend any tutorials for unreal engine multiplayer? (Actual recommendations, not just a random pinned message you've never read)
If you haven't read the network compendium - you're doin' it wrong
Which is a pinned message
yep, pinned compendiums
I'll give it a try
Yeah I just didn't want the response "check pinned" 😭
Well you should
It's not like pinned messages are pinned because they are fancy wordings.
They are typically solid answers to common problems/questions
Hey smart people. Any local multiplayer gurus out there know the best practice for retrieving local player controllers? I'm trying to set up my drop in/out multiplayer and HUD but it's acting wonky.
Most are irrelevant and just plugins and forums that don't have anything to do with basics, last time I tried this I tried to read the persistent data compodium as a start
That’s the persistent compendium not the same one we are talking about. Go here: #multiplayer message
Also watch this video: #multiplayer message
Both are pinned messages just hidden away near the bottom of the list.
So it seems that no matter which player controller index I use to set input mode and show mouse cursor on, it changes those variables for all of my local player controllers.
Getting this when attempting to create a session via a dedicated server. I am doing it thru blueprint.
I understand why, but don't know the solution? Dedi server has no player state :/ Anybody created an online session at the start of Dedi turning on? Or this is only done via cpp
I'm trying to find a solution, apparently I can create a Dummy Controller but this fails as it doesn't have a Network ID. Would I be able to manually assign a Network ID? The next solution is to create a client game instance that joins the server, which then creates the session. Not sure about this tho...
Why is it so hard to create a session that can be found in a server browser hahaha
wow
You can use the Player Array from the gamestate (show inherited variables) and then do a foreach loop to isolate the individual controllers.
Started next part in this course that jumps into multiplayer, but having trouble producing same results.
https://prnt.sc/YAdHrWJP4Wvq
https://prnt.sc/SwOea40p-tkh
https://prnt.sc/unKhEo5-vpUO
https://prnt.sc/xVOWIif1RJJ9
Double checked if static mesh was replicated as well in the Blueprint. Not sure if that matters.
Thanks. I'll try this. I'm not sure it'll fix my issue though. I'm able to retrieve my controllers from an array I made in my GameMode but trying to set input mode to UI only when player join causes all of the local controllers to switch modes. It's wierd
GameMode is server only
GameState is on both server and client
If you ever find yourself not sure if its the server or client executing the blueprint you can always pick a node and place a breakpoint on it (F9), then as you step through the logic (F10) it shows in large yellow text which net mode the process is currently on while debugging in the top right corner of the graph.
Anybody?
Right. This is a local splitscreen game. I'm not running any network code as yet.
So you made an array of controllers in the game mode right?
They should be using different local controllers because I used CreateLocalPlayer to create additional local players for each joining controller
I don't know enough about split screen to help, sorry.
It's like multiplayer, but not.
No worries. Thanks anyway. This splitscreen stuff is wierd.
Guys is this a good practice to code like this for setting variables on client and on server and also avoiding the value to be changed by the client on the serverside too?
Generally you'd use an OnRep.
- Client ask server to change a variable
- Server changes variable
- Unreal replicates this back to the client
This is the general flow.
For some fairly rudimentary prediction, you can also change it on the client as well. Then ask the server to change it.
OnRep should be your default way to do something barring some other circumstances
i heard that OnRep has a bit delay and that events are instant currently i'm doing it this way
i use sequence set it on client and further code to follow and on the next pin i set it on server
no
well
that's not the way to think about it
but to clean up the code and have not many events i am thinking of doing this way
Onrep is stateful - that is the important piece.
btw why is Idle a replicated state at all?
it should be derived right?
if you haven't done anything in a while LOCALLY, you're idle
the way i am setting my movement i generally need to know if the player is idle or not and to not check the velocity of the character pawn again and again im using onidlevariable
When do you set idle = false?
when the player pressed any movement button W,A,S,D its true and when the player take the finger off its set to false
for example i want the variable of sprint to only be true if the player is moving and not standing idle and pressing the sprint button
it all works correct i just want to be sure that the client cant change the value of this on server event
here
since i heard that you should never pass values in the on server events
Eh - it's fine. Can be a security risk, sure. But it's fine in a lot of scenarios
i see
Is it possible for someone to be jumping and sliding?
What about jumping and sprinting?
Or any kind of those combinations?
Because this is ripe for a state machine.
thats for jumping
basically when a player jumps the idle is false
and as soon s he lands and not moving the idle is true again
yeah future proofing for animations
Not sure why you can't just do it the way practically every game does it in Unreal, but this approach is a maintenance nightmare.
Having each "state" be a bool, then you having to go through and manually turn off other ones is highly prone to error.
And absolute garbage when you want to add more states.
There is absolutely no future proofing in this code.
You're coding like it is 1993
And even that's being generous most likely
yeah i agree with maintenance nightmare and when i used a function like this its hella easier thats why just want to know that is there a security risk this way lol
I'm not even talkin' about security concerns at this point.
what is the way every game is in unreal?
Just your displayed architecture is quite poor.
The animation blueprint derives the anim state machine from the character stuff. Such as velocity or certain actions, etc...
The way you're doing it, yes, it can work. It's just....poor practice in most cases.
Having a bool every once in awhile to represent a simple state is fine.
i am not talking about anim state machine i am talking about what is the way to do it properly in the character pawn for movement
as this code is for movement character pawn
Just...move the pawn
If you want to do states, create a state machine and separate states.
Some people like using something like Logic Driver to help with this.
How many situations does a player get into where they ARE pressing a WASD key but they aren't moving?
(It's a plugin)
fwiw ue5 has the state tree too
I don't know if the ST would be applicable in this scenario. This looks to be for the player specifically.
guys guys i think you misunderstood me and especially with the State in the name is misleading let me describe again
StateTree is generic
It is, indeed.
All I see is booleans being used for a single state. If only one can be true at all times, an Enum would be better
Just handling the back n' forth between player and ST might be a bit wonky. Haven't tried in the context of player though.
@thin stratus Hmm - after a little thought, I think I might know how to work with ST in the context of a state machine for the player. Still think it is a little wonky, but meh.
this is my movement code i am using the State word not for animation statemachine stuff its basically me using it for character's state like lets say in which stance the player is idle running, sprinting etc
i am using boolean varaibles so i can set the speed differently for running and sprinting
State machines aren't exclusive to animation
ahhh
thats why i want to know the proper way to do stuff hence me asking if this is better as i wont have to call multiple RPC's this way
for example that same code decreased to just this with all those rpcs not needed
I mean, one thing we've been saying or asking is if there is a need for all the booleans
If you want to communicate the "state", and only one of those can be true, then you could use an enum
yeah i can use enums i tried that months ago but i think i faced an issue somewhere when setting states and never used it so i guess i can use enums as that will be cleaner and efficent
On top of that, if this is a Character, then some of those things can be retrieved from the CharacterMovementComponent
Overall, 100% correct Movement Code in Multiplayer in UE requires C++ anyway, so if you do it in BPs there is no real right way anyway
i will use enums sa i will need these states so i can change player speed if the player is running or sprinting etc
yeah
ig whatever works but its good to be cleaner and efficient ig
The thing is, the "Idle" part for example is kinda redundant. If you want to know if the player is idling, you can get the Velocity or Acceleration and check if it's 0.0
yeah i know i just didnt want to use a variable to be specific lol but i will try enums and stuff
fwiw there is also the option for a bitmask
Not sure how to create them in BPs
Might just be a checkbox in the enum
Then you can still select multiple if ever needed, but it's based on an enum
oh ok thanks for the info
Trying to make a GameModeBase where I capture some parameters from the connecting clients FString& Options and use this to adjust some things on the character that gets spawned for them
I see the options available as inputs in InitNewPlayer, PreLogin, and Login
But I'm confused on where best to capture these, and how to store these options for when the player should be spawned. The spawning usually happens on HandleStartingNewPlayer_Implementation, right?
So do I need to cache those optional parameters ? Maybe with a key of UniqueNetID and then look them up again in spawning function? Thanks for any advice 🙂
An important thing to remember when working with multiplayer is that player inputs (keyboard, mouse, hand held controller...etc) are coming from the client not the server. They must be "uploaded" to the server via RPC (Remote Procedural Call aka run on server event) because the server doesn't know about that event happening because the client is running their own simulation of the game using the server's replicated variables to represent other player characters and updating world actors.
Whereas when you're dealing with an overlap or hit event between two actors then the server and client both run the code (if the actors exist on the server and client). So in other words you wouldn't have to use an RPC because you can just check with Switch Has Authority to separate server and client logic.
i had a good understanding about the first part however didn't know the 2nd part Thanks very useful to know appreciate that
Another thing I find very helpful with multiplayer is to make use of breakpoints. Not only does it help with general debugging variables and logic flow but it also tells you if the current blueprint execution path is server or client side with big yellow text in the top right corner.
i just realized using Enum i don't have to set the enum for player moving stances idle,running,sprinting etc inside an Rpc i just need the logic of all those stances in an RPC and the code is working as intended and replicated even if when printing the enum values on the server its not what it is on the client however nothing wrong is happening
If only there was a way to tell about client, listen server, server, etc from VS/Rider cpp debugging
ah i see thanks
that be so neat haha
is that how it is supposed to be @thin stratus
like i dont need Rpcs for some reason but only for the logic of sprinting aka the set walk speed stuff
hello, I need to make a door that only certain players can pass (is a mesh of a door and a box collider that acts as an invisible door that doesn't allow the player to go through). But when I use the "Set Collision Response to Channel" (of the player capsule) on a server RPC (I implement the RPC on the playercharacterBP) only the server gets updated and doesn't replicate with the player client's capsule. Then I see that the capsule can be marked as "Component Replicates" but my client still doesn't update. Any ideas on what it could be? thank you
@thin stratus https://cedric-neukirchen.net/:
yeah I got the same error but in a multiplayer video they put the direct link to the pdf:
https://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
thanks
Only variables marked for replication will be replicated. In the case of a collider, the collision response is not replicated. 'Component Replicates' is just a switch to enable/disbale replication for the whole component.
You might want to try adding your own replicated variable on the player to represent whether or not they can pass through the door, and in the OnRep function, manually call SetCollisionResponseToChannel on their collider. Then you just change the variable from your server RPC.
I'll try that right now, thank you!
I'm noticing some weird behaviour or something i dont quite get about the "Is Locally Controlled" node on ListenServers. In this example i just wanna create some widgets in my character at begin play, In this case since its a listen server the server itself also has a player that he controls locally but for some reason the server will never realize this immediately in my case but eventually not realiable but most of the times after a short delay. since its not reliable (also tried with higher delays still not reliable) and the server will run trough the begin play on every client too i really dont wanna loop trough this or anything till he eventually gets it.
I would enjoy some insights if someone does know what goes on behind the scenes or if theres a another/better way to catch the call from the ListenServers local pawn.
@fossil stratus BeginPlay is called to early for Pawns to be able to resolve their PlayerController (which is what tells them if they are Locally Controlled).
You will probably want to use a different setup method.
Are you using UE5?
Pawns have a function you can override in Blueprint that tells you when they were "Restarted"
This is what you want to use instead of BeginPlay in most cases.
that sounds awesome , I should look into override functions more often! thank you I will directly give it a try
works like a charm, i really hate using delays to fix these things 😄
hey guys can anyone tell how to edit skeletal mesh
Ok so an update to help those who will face same issue as me, I narrowed down my problem of server RPC not being fired from client owned actor, it turns out it is world partition related and the same BP won't work in world partition maps only ( tested with 2 maps) unless playing as listen server then everything works.
If I want to make it work in dedicated server setup I need to set the BP 'Is Spatially Loaded' to False , I tried using streaming source component on Characters but couldn't get it to work.
I also have a strange issue in which making RPC Reliable in some area make it not fire!? It should be the other way around.
Yeah I will have to move hoster eventually. Digital Ocean Droplets and the database of that website just hate each other
Where is the best place to have my player stats for a multiplayer game?
In the player controller override
OnRep_PlayerState()
Hey, search is failing me. Is the AdvancedSessions AdvancedSteamSessions still a go-to option. Or is using some form of EOS or other EOS plugins(such as EOS Online Subsystem) the recommended path nowadays?
I know a lot has changed in last year and most things I am seeing is older than a year.
Either way can work. I'd say it depends more on preference and platforms you want to support. I've used both Advanced Sessions and Redpoint's EOS plugin within the past year. EOS requires a bit more configuration but then you aren't dependent on Steam or any other platform.
best to ask on #online-subsystems
Can you replicate material ref? or are they like widgets and only exists on client?
A material reference isn't an actor, so it could be a replicated variable on a replicated actor, sure.
Hey guys!
What is the proper way for clients to notice that another client has joined the session? AGameStateBase::PlayerArray has no OnRep function that I can bind to.
Hi guys can anyone share any insight on why this happens:
*On begin play the ball is spawned in the wrong location on the client but correct in server.
*The ball will snap to the position when it's interacted with.
The spawn in wrong location thing doesn't happen if simulate physics is off...
Actor and component replicates, as evidenced by movement after initial contact with the ball.
Hi.
I'd like to replicate a property with the condition "COND_InitialOnlyOrSkipOwner".
In other words - I'd like the property to always replicate the initial value and then skip Owner for future updates.
This condition does not exist right now.
Is there any way to add this replication behaviour without modifying the engine?
Alright I ended up overriding GameStateBase::AddPlayerState
Hi, my actor is replicated, but when I execute 'Explode Now', it runs, but 'Explode Server' does not.
What could be the reason?
I am executing it from another non replicated actor.
Server and Client RPCs can only run on Client Owned Actors
If your Actors sits in the middle of the Map it is usually not Client owned, and also shouldn't (also to make it Client owned you need to be on the Server to begin with).
If you need to perform a ServerRPC, you need a Client owned Actor or tunnel it through one
E.g. PlayerController
Working now thank you!
Then don't? Delay is bad juju in networking code.
I am making trails in multiplayer game. I call set active on niagara component, it worked. Now I try to use gameplaycue, how to do that?
i have set up the gameplaycue tag, and call execute gameplaycuewithparams on owner, but it didn't work
Is there a downloadable pdf of this
The one that was linked
It sits on an ftp. The website just links to it
I still would want the blog to be the pinned message for obvious reasons, BUT the new version of the compendium will be a website on its own anyway
Whenever I find the time to finish it
f I guess I can't save it on iOS then
Progress going decent though (slide 27) hopefully it doesn't just "jump" in complexity too the point where I can't put 2 and 2 together
Make sure you practice often
What would you suggest for (FPS) multi seat vehicles like tanks? One player drives the vehicle, the other one controls the turret.
Should the turret be a separate actor, so that its controlling player can be its owner and replicate the input via server RPC within the turret?
Alternatively, I could probably set the turrent rotation locally, send to rotation the to the server via PC/Pawn RPC and set it also on the server. But it does not feel very self-contained.
Is the vehicle a pawn that you possess or just an actor your pawn sits in and routes controls to?
Just an actor which is not possessed
atm the driver char is set as the owner
so that the driver can replicate the input easily within the vehicle
but as there is only a single owner allowed, the shooter is not able to replicate anything
In unreal you mean?
Yeah
Wouldn't make much sense to read the compendium for UE and then go off and practice in Flax or something, lol
Practice could also mean going over the material by reading it again though
(I was more of hoping you'd have any ideas on how I could practice in unreal lol)
Literally just make extremely small games.
Get 2 people connected. Introduce packet loss.
Ignore fancy graphics.
The advice is always going to be the same. Make very simple games.
Note - a wave based shooter is not a "very simple game"
Then do this many many times
Introduce packet loss?
To try and simulate lag
Make a super simple collecting game. But networked.
Then learn how AI functions on the network.
Then learn how to do items.
reading is hardly any practise nor helps with memory
True
eventually you'll run into issues and then you'll read the corresponding pages and you will learn for real
it's the only way to really learn imho
Once you do these pretty small things. Then combine 'em and make a wave based shooter
(if you want that is)
But seriously, do small things
Start with a physics based voxel MMO
BP only at that!
Hmm idk what I wanna make tbh I just want to learn so I can get a job
Godot is my hobby coding
Yeah - that ain't how the real world works.
Without an aim, we get nowhere
Make something unique that shows that you know what you're doing
You need to prove that you can do it.
nobody will give you a job because you can make a pretty single player shooter. Do something new.
Doesn't have to be something new
Alright
Yeah maybe not new but that at least demonstrates the ability to do something beyond a dude that can walk around and look and make bullets pop out of a gun
Just claiming you can code will get you nowhere
Think of a hard problem and try to do it in games. My hard problem is graph simulations.
Sure - but if you make a complete game out of this, that alone would still be more worth it than people who only do what you described.
ye basically not an Unreal sample clone
I was thinking about making some random indie game, maybe something like muck
Especially if it is networked
If you made a Muck clone from scratch that'd be pretty good.
ye usually network adds like 50% more work, or even more
If it was a bunch of asset and feature packs stitched together maybe not so much.
Should I try practicing before I read the entire pdf? Or just focus on reading
assets are fine if you're trying to demonstrate programming chops.
Code plugins not so much
@graceful viperhttps://youtu.be/NjYICpXJ03M?t=24
Lex Fridman Podcast full episode: https://www.youtube.com/watch?v=_L3gNaAVjQ4
Please support this podcast by checking out our sponsors:
- Four Sigmatic: https://foursigmatic.com/lex and use code LexPod to get up to 40% & free shipping
- Decoding Digital: https://appdirect.com/decoding-digital
- ExpressVPN: https://expressvpn.com/lexpod and use c...
the part i linked you at
The PDF covers the basics more or less. I would suggest you at least read it once
Also is anyone able to like send a pdf of the compendium? I can't install it on iOS and my data is pretty bad on the bus
Wouldn't that be a problem either way if your data is bad?
Website should be fixed again fwiw
Freaking Digital Ocean
Yeah well said
Just have something you want to do, then try to do it.
very very good advice
Oh I can access it with no internet, cool
Don't you speak ill of my el' cheapo option 😅
I compiled the engine from source on a DI instance one time
It's fine. but WordPress and its mysql database stuff always breaks on it. And I googled for it and they all have the same issue and no real solution, at least none that sticks.
I even got a stronger droplet
it was looking like it was gonna take a week on my el cheapo instance so I flexxed it up to max cores and ram and it did it in a few minutes.
I will just move it over to hetzner eventually
but if I had forgotten to flex it back down that woulda been expensive. Ended up costing me like 5 dollars in the end.
Don't think I've heard of hetzner
Aren't you apart of the 5950x gang?
Or was this in the before times?
I was doing a remote compile so I had built engine on the server. So I didn't have to do cross compiles or anything, just tell server to rebuild and relaunch.
Hetzer Online is a German company
They are doing this for quite some time, 1997 or so
And they are quite big by now
We have every other server on there by now
Just not my private blog
Think they have a Wordpress setup for 2€
So they are even cheaper in total than DI
+- diskspace, but the additional diskspace on DI compared to Hetzner was also cheaper (on Hetzner side)
My wife moved all the servers so I have no overview. But that's at least what I see on the bank statements :D
Ooh not bad, and right next door in Asheville
looks like it's actually Ashburn VA but still close enough
ah thanks I totally overlooked those channels!
is there a delegate that allow us to react whenever our game net mode changes? As in, if I'm Standalone in a menu and then I join a server and become Client, is there a way to get alerted to that?
reading through the docs, I wondered how accurate this was
Does the server really tell clients to do vfx? Can't the client just do the vfx locally based on the bullet being spawned? So its just one server->client event, and not 2 (or more)?
Not everyone does step 3
If you have the bullet being spawned or the gun being fired on all machines then sure handle it locally
just seems excessive to send that aswell
In more milsim games the bullet doesn't exist anywhere but server since you can't exactly see a real bullet
but i guess if step 3 doesnt happen, then step 4 must be done from server i guess
yeah, ok gotcha
Projectiles are tricky. Nothing feels worse than hitting on your machine but missing on server
True that! Glad i dont have to handle it 😄
Hey quick question guys I set up the new enhanced input system it appears to be working for my client side but not for my host / server anyone run into this issue
How are you adding context mappings?
scratch that i think I just had to add a delay
and it works fine now
seemed to be maybe it was just firing to quickly and didn't give the server a chance to start maybe?
The pawn won't have a controller at spawn on the server, because beginplay is often ran before possession call.
But that isn't the real issue. Your issue is that you're adding context mappings to the controller from a pawn.
Pawn is not a control handling class. It just receives inputs. Your PlayerController should probably be handing this kind of stuff as it is the control handling class housing your input stack.
Also. What is that interface event? Why are you using an interface event where you could just do a simple CastToPlayerController?
yeah probably new to BP but to my understanding should be using interfaces for most everything to keep it optimized right?
Thanks for the heads up though so I should pretty much have this whole code set up in the PC instead of the pawn
That isn't an optimization. Interface events are actually runtime slower than a cast. The slow part of a blueprint cast is it's validity check, which you are also doing after that interface event.
Casting is effectively free, there is no runtime cost for it. The only cost for casting is that when you have a cast node, you need to have that object loaded into memory when an instance of this class exists.
Unreal runs by loading CDOs. These are Class Default Objects. To spawn an actor or create an actor component, or construct a new UObject, you need a CDO. This is a base class that acts like a template that Unreal can copy to instantiate a new instance of that class. Putting a cast node to a PlayerController in a Pawn class is free. Player controller is 100% always loaded, so there's no downside here.
Generally the reason people avoid casting is because they do not follow basic principals by putting code in correct classes. You should have a layer of code only classes that most of your game can work with. It shouldn't matter if these are always loaded as code only classes are basically nothing in size. But people cast to characters like bosses in their character pawn and that boss has heavy meshes and materials and sounds. And then only use said boss in one level. But now said boss is now loaded in every level that the player's pawn is.
But here's the thing. It isn't the cast node that does this, but hard pointers and hard class references. These are the light blue type variables and purple variables. Any time any of those exist in your blueprint, these cause this memory connection requiring the other thing's CDO to be loaded. This random variables, function arguments and function returns. Both of which also apply to interface functions.
Interfaces are largely pointless outside of patching logic you cannot inherit. Interfaces are best used to make different things do majorly different things based on the same thing.
Example of this is a player's input pressing F and expecting a lightswitch to turn on a light, but also expecting it to start dialog with an NPC, to mount a horse, or to pick up an item.
oh damn ok well thanks for the fast response and thorough answer
so esentially instead of where I would be using interfaces I can just use Cast system for the most part and save myself the time
For a lot of things, casting it pretty standard.
Mainly the reason to avoid it is to avoid loading unused assets. But that is just about making a code class layer and avoiding loading assets on that class, but having inheritors from it that inherit functions you'd call on their parent. And this also brings in soft class references to use.
Also worth noting that the whole "loading" bit is completely irrelevant to casts on the C++ side of things because all C++ classes are always loaded. It's only an issue for blueprints casting to blueprint types (and it's not exclusive to casting, it applies to any node where you "hardcode" a class parameter).
Do note - in multiplayer, whenever you are "solving" a timing problem with a Delay node, that is a poor solution and ripe for breakage in a real-world situation.
Yeah. I mentioned that above. 😄 Any sort of hard pointer or class reference relating to any variable or function parameter or argument. 😄
damn really appreciate all the feedback new to the engine, everything I Was hearing was casting is the devil
lol
Because someone popularized it and everyone relies on YT tutorials. And then most of those YT tutorials are just regurgitating what some other YT tutorial says. All the while most of them not actually releasing games.
I can see how that becomes an issue
😄
There's also reddit posts about it. Like one really popular google search is some crier was complaining that he inherited a mess of a project and was now the only person left on it and blamed 100% of it on casting use.
(i've looked at the FNetGUIDCache warning and seen that it fires because the mesh isn't replicated, but i do not understand why the player movement warning would only fire when standing on other meshes)
yeah I'm making a relatively small game
dunno when it goes into account for casting but i feel like maybe i won't hit the threshold
and good to know now I need to put my movement in my PC and make the reference the spawned pawn.
I think I ran into that problem a while ago locally creating ISM components. Don't remember the fix for it though but it's basically just that your object isn't net addressable. Might just need to replicate the component and then have the client do the generation.
To be clear, the pawn still does the input. The only thing that needs moved to the Controller is the mapping context.
They didn't say to put your movement in PC. They...nevermind, he replied.
I do my mapping context in my PC's possession call.
I know Lyra just does them from their experience sets. You just get a blob of mapping contexts at the start of the game.
alright thanks lemme figure out how to add that there ❤️
Pretty much the same way. Just move your Beginplay stuff from the Pawn to the Controller. Same identical call, you just don't need the GetController part cause you'll be in the controller itself.
i'm gonna ask a real noob question here, is it better to keep all your code on one eventgraph, or split it up between each function, and is there any performance impact for that
perfect thanks got it running
That's a style choice. I don't think I've ever use more than the default graph except for the auto generated sequencer one. But there's no performance difference outside of the editor.
I like to separate my graphs into server/client graphs.
So all server events would be in server graph. All client events would be in client graph.
Then the default graph is just setup stuff mostly.
Only if there are multiple events mind you. So if there are like one or two, meh, I don't care.
ooh not bad
generally speaking don't assume that something is a performance problem unless you have profiled it properly.
ITs posible made all replicances in Blueprints or is necesary C++ ?
Depends on what you're trying to do and how complex it is.
I'm trying to call PrintTest from server. UBlock is a component that inherit from UActorComponent. Actor which spawns the component is set to replicate, as well as function that spawns the component is setting it to be replicated. What else might I be doing wrong?
@obtuse field You dont show us where PrintTest is called?
.....
Show us the code mate... lol
Where its called.
If its not being called anywhere in code, then of course it wont be called.
void UBioProgrammer::BlockTick(const float& DeltaTime, UChunkBuildingComponent* ChunkBuildingComponentReference)
{
Super::BlockTick(DeltaTime, ChunkBuildingComponentReference);
if(IsRunningDedicatedServer())
{
PrintTest();
}
// UKismetSystemLibrary::PrintString(GetWorld(), "ABC");
}
Its called here
Did you breakpoint that line?
Which is called every tick
W8
For some reason, it started working now...
Idk
I've been trying to debug it for like 30 mins, and now it decided to work, lol
Hello! A bit of a weird question, I'm still a little novice in a few areas, and so I'm not sure if this is related to multiplayer, but I suspect so. I've been in the nightmarish process of trying to make my first test build with my dedicated server model game, and following the steps. I finally have the client and server solutions built and client and server cooked. However hwen trying to run dev client through VS, I've hit a hurdle immediately, in that the UI widget isn't spawning. I have it added to the viewport by the player controller on begin play, and it works in the editor as a Client, so I'm not sure where I might start debugging this. If anyone has a suggestion, that'd be great please. Thank you!
@fathom aspen Can I just say thank you so much for your compendium. I had an issue today related to travel that I was stuck on and needed to get it fixed for a looming deadline and it was so easy to find the info I needed in your compendium 😍
Glad to hear that it helped and that info are easy to find 😄
Hi question, so if I wanted to implement a turn based mechanic in a multiplayer game, that logic should be implemented in the game state and not the game mode right because the state of the turns needs to be shared across the clients as well?
Yeah GameState / GameMode can get a bit blurry
state in gamestate and logic in gamemode is sometimes how its done
Tell us more about this Widget. It is failing to load on the client or the server? And post a pic of the code where the widget is made
Dedicated servers don't have widgets at all
Hi guys, do you have any tips on how to make my client to be able to interact with 3D UMGs? so far only the server can interact with the 3D UMGs. 😵💫
What do you mean by 3D UMG’s?
Widget components?
sorry quick follow up question but for example if i had a series of phases for each player like move and action phases, would it be wise to store those as custom variables in a playerstate? or is that unneccesary because i can just keep track of that in the gamestate already?
If it's exclusive, having some struct representing the phase on Gamestate is probably fine
It'd look something like
GamePhase:
Player PlayerWhosTurnItIs
E_TurnPhaseEnum TurnPhase
And everyone can locally use this in an OnRep to set state
It'd be something like
OnRep_GamePhase -> branch on PlayerWhosTurnItIs (check if local player, etc) -> switch on PhaseEnum -> etc etc
So i guess i had another question regarding like the purpose of usage of playerstate implementation and when to use it aside instead of storing information in the gamestate. Like if my player had stats, i would store that in playerstate right?
Turn based game for an indie multiplayer game is a good idea. I wish I had a good turn-based game idea
it's much much much easier than live action and that's easier than FAST live action
also thank you so much for all the information i really appreciate it. This stuff is kinda confusing to me and the compendium is kinda deep lmfao
Start by sketching out your functions.
The main function for your GameMode / GameState will be GoToNextPhase or whatever. That's where all the logic for what to do next will live.
and don't multicast anything rn
use OnRep
okay thank you so much!
3D widgets
As in a widget component?
yeah
it's wierd that when running in standalone, the widgets are clickable but function only works well on server side. not on clients. but when running on PIE, I can't even click the widgets both side tho I can hover on them.
is there a simple way to set simulated proxy's character mesh relative location? The cmc keeps overriding it 🙄 I guess I do have to override something in the cmc
how do you set up a dedicated server on aws? is there a template?
I'm naturally only trying to create it on the client :) I'll grab a screenshot soon as I can, but in the player controller's begin play I'm simply doing ah IsServer check, and if it's false then I create a widget and add it to the viewport.
And so yep, that works fine when PIE, but if I launch a Development Client from VS then the widget doesn't appear.
show your code
Yep! Just got to my PC again, sorry. This is the entire thing, actually, as it's just the PlayerController for a super barebones frontend, which I intended to be used for connecting to the server. It's probably something really silly I'm missing:
try is dedicated server
standalone might pass IsServer
i know it passes Authority
I should note that this works with the editor set to Client is well! In case that makes a difference
I can try it though!
Client isn't standalone
when you fire up t he game, it's standalone
Ah right, I thought you might have meant PIE set to Net Mode Standalone
I shall try it now. Thanks!
There's really not much use for IsServer IMO, I use IsDedicatedServer and HasAuthority
I'll take that into account, thank you! How do you tend to do your checks in code? Do you use GetNetMode()?
And ah unfortunately that didn't seem to change things! But I'll quickly try something.
Okay, I've noticed something after sanity checking, and that's that changes I'm making in editor aren't being reflected in the development client build. I just tried adding a mesh into the level and that didn't appear, so I'm not sure if any of my blueprint changes are reflected either.
I'm a bit new to this side of things, do you know how often I need to cook content?
Ah wait, cool, looks like the answer is "with any change in editor" because after cooking content, it works! Thank you!
Question in the same topic guys, how do I check if it's the server/client from within another class other than the player character?
I'm trying, and it's not working:
if (PlayerCharacter->GetLocalRole() < ROLE_Authority)
Couldn't get HasAuthority to work either
Hello guys, i need someone pretty skillfull with multiplayer systems, i m full of doubts
need to GetNetMode() from an actor
Hey guys, you know when you boot up the game in PIE as a client there is this inital camera thats just at (0,0,0) halfway in the ground before the player posses a pawn
I'm trying to learn how to replace that, I kinda got to the LocalPlayerClass but the documentation is very light, can someone help me on this?
What do you need in your project ?
Place a player start actor in the level or you can override FindPlayerStart in the game mode
nah that doesn't work, also I do have that, but the issue is the "fake" local player that is your camera goal until the game spawns you in the replicated one, somehow I need to give that a camera
the player start only sets where the pawn will spawn but the issue happens before
This is triggering(even on client it spams "Hello" - given i hit a or d ), but the Client cant move, server can. why could that be?! :S
Is said thing possessed?
Id hope so? 😄 this is in the GameMode
and this is in PlayerController:
and this is spamming the correct spawned actor, this means its possessed,right?
Hey. So im trying to use EOS, and everything for these widgets works well, but when I package the project, it no longer sends the player to the designated location. Also online servers hosted without LAN do not show up for other networks. Im using 5.1.1.
I made sure to set the list of included maps.
Everything works in editor just fine.
Why are you using the game mode to spawn the player?
followed a tutorial 🙂 better to do it somewhere else?
Because you call it from the player controller, so why not use the player controller
Are you sure that the player character is set to replicate?
well basically as mentioned, i followed a guide as im pretty new to unreal (like 2-3 months in but 10hours a day ^^) so i hoped it would be fine 🙂
but can move it np ^^
u mean in BP_PlayerCharacter in class settings? then yes
You don't need to move it, it just feels unnecessary
well he told me to do it this way, so i did 😄
if youre learning you hope ppl making videos show you best practice etc but obviously its the internet so everyone can make videos..the good ones and the bad ^^
Set the owner and instigator as well, Owner = PlayerController and Instigator = PlayerController->GetInstigator
Exactly, but sometimes it is just personal preference
no change, but a little update:
The server sees the joined client Character, but the client doesnt see the server character.
dunno if that helps 😄
Do you know if there's a specific reason this tutorial isn't just specifying the PlayerCharacter in the GameMode's DefaultPawn class?
Even if it would, it wouldnt be useful for my needs.
I got a main menu->Start server->clients can connect and then once the map is loaded youll get a screen of your characters on that server that you chose from. Aka I dont even have a pawn at that point only the PlayerController showing the UI with the characters and then you chose it->click "join game" and then you get a pawn
Are you sure that all the replication settings are correct?
the thing is this IS triggering on the client, just nothing happens 😄 😄 😄
Of course it's replicating. It's spawned in the GameMode, and client has input prints.
Setup_InputSystem is called by a PlayerControlled Run on Owning Client function, is that an issue?! does the server need to do this?!
Well, that'll probably be your issue.
For starts, I'd recommend not doing this in the Pawn. Pawn doesn't need to care about Context mappings. Move this to your PlayerController's Beginplay behind a IsLocalController.
Should work well.
unfortunately not 😄
Well, no, I derped. Just realized you wouldn't be getting prints if it wasn't working. But this is still a better place for it.
kk, keeping it here, as we get same result 😄
The character isn't stuck or anything is it? O.o
nah lol, server can move about
What happens if you spawn it high up in the air? Does it drop?
Hmm. Not dropping implies it's not possessed.
The CMC doesn't normally update without possession, can't remember the pathing or reason why.
cmc=? 😄
CharacterMovementComponent.
Hello, does anyone know of a way to make world widget component ui's like these replicate?
You don't replicate UI. That UI should be displaying the state of an Actor. The Actor should replicate that state and the client's UI should update to reflect said replicated state.
You say "you dont repliacte ui", correct is "you cant", correct? as in WBs cant replicate anyway?
im not trying to be pedantic, i just heard WBs cant, just wanna confirm 😄
So there's no simple way :c Thanks for the answear
There is a simple way.
Replicate actor
Actor has a variable that has those values
Replicate variable
Widget gets updated based on that variable's OnRep
The short answer is that no, they cannot replicate.
The long answer is that yes they could probably replicate if you did some hacky stuff and made them subobjects of an actor, and replicated them, and got around the issues of what that would entail. But even if you pass this "could" phase, you step off the ledge of "Should". It's mostly just a case that UI isn't a part of gameplay. It's a visual like a particle and should be treated as such. You don't replicate particles either, you normally replicate state on an actor and play them locally. UI follows the same ideal.
ye, thought so 🙂 thanks for the explanation ^^
cant be so hard that if i hit a button that i create a character that runs around 😄 😄 😄
I need to be stream in browser, that has a in-game currency and some other features
I know, but that is the not-simple way of keeping every possible widget status as a variable and replicating. I was hoping for a secret replicate button that would do this for me 😛
If this ain't simple to you - you've got a pretty steep hill to climb of nothing but complexity.
Works 👍 I confirm the simplicity of this method
Guys:
UFUNCTION(Server, Reliable, WithValidation)
void Server_Fire();
bool Server_Fire_Validate();
void Server_Fire_Implementation();
if (IsNetMode(NM_Client))
{
UE_LOG(LogTemp, Warning, TEXT("Client request the server to shoot"))
Server_Fire();
}
void AWeaponBase::Server_Fire_Implementation()
{
UE_LOG(LogTemp, Warning, TEXT("Shooting from client"))
}```
Anyone with c++ knowledge knows why the implementation is not being called? Just the first log appears
Likely the client doesn't own the player and thus can't call server RPCs on it
Can you elaborate on the fix a bit?
Well I just pointed out the potential issue. Your player is not the owner of the actor, for the rest, I suggest to have a look on the linked posts and get some more idea of the network system from unreal, or google a bit^^
Sure, thanks!
Hello team.
This code is failing. I get the output Player Pawn found but I do not get the Locally Controlled
I call it in blueprint here
I am running a Switch Has Authority node before this too, so I am sure it is my local player sending the info.
Anybody know what is going on?
For context, I am running a dedicated server and two clients that find and connect to the server. I then attack using one client, hitting the other.
All three are on a single PC.
Been stuck on this bad boy for the best part of a day. I have tried passing in a Pawn, a Controller, grabbing the Player State and working from there. I never get past the local check. I've tried with a controller and changed it to PC->isLocalController and PC->isLocalPlayerController
Is this called on the server?
Client
Where do you check that?
Is locally controlled would only be true for the local client. Any other including the dedi server will return false
The Hit Detection function calls the Process Hit within.
This Switch Has Authority should mean the local player right?
No
ooooo
If this is a replicated actor then the server has authority
While authority doesn't equal IsServer in all cases, it does on a replicated actor that is spawned by the server
If you spawn an actor locally only it would also be authority for the client but usually no one uses that node on a locally spawned actor
Ah yeye that makes sense. Okay. I am looking for the client that controls this character then..
Nah this actor is spawned by the server for sure.
Does the tick have to call locally?
If this is a character then just swap the has authority with is locally controlled
Then you have it call locally
Its part of how I am running things.
I am allowing the player to attack using a GAS input system. If they hit something, send the info to the server, rewind to the right tick etc.
Brilliant!
Hey guys! I have neat optimized projectile system that allows for thousands of projectiles to be rendered - but I ran into a problem of networking them neatly. I had a potentially dumb idea of compressing the struct that stores the projectiles with LZ4 and hosing the clients down with it every networked tick. Seeing as LZ4 seems to have crazy compression times it seemed to me like it might work - any idea if this is dumb?
Question, when I set my movement to flying all my collision boxes stop working is there a work around for this to enable them?
this is very broad topic, which is the context/gameplay like? how do those projectiles behave precisely?
compression won't solve a badly designed system
@civic seal make them deterministic and so that instead of replication location you just replicate spawn point and initial velocity
you can even optimize further (instead of spawning replicated projectile actor on server) keep datas on one compact struct and replicate it
I'm testing local multiplayer, and I'm using 1 Keyboard and 1 Gamepad. Both are being assigned to 1st player. I turned "Skip Assigning Gamepad to Player 1" to true, and they're still both assigning to 1st player. How do I get the keyboard or gamepad to assign to player 2? I would prefer a solution using Blueprint, but I will accept any solution
how do you restart a session?
I'm tryign this but does nothing
Is the event being called? If so, is the function on Game Mode being called?
yeah its when I press the button its inside of a widget
will a display name miss-match cause an issue with replication? I noticed one of my actors fails to replicate a call to the server while being set up like many other systems, only difference is that due to how this is spawned (un-replicated dummy actor spawned locally first) the naming doesnt always match the server. IE - Server sees: Actor_0 while the Client sees: Actor_1.
This is a strange question. You're asking if an unreplicated actor will have trouble with replication? It won't replicate....
If you're spawning an actor on the server in the client separately, and you need to be able to reference them as if they're one actor, you'll need some referencing system other than display name because that won't be safe
I have used maps for this purpose before, where an integer key on the map points to the actor you want
Sorry I didnt explain it very well -
I have a vehicle building editor that spawns an actor (vehicle piece) inside of a widget. The actor itself is replicated but since it is spawned inside of a widget, the event of it being spawned isnt replicated to the server. When the player makes a decision to place a component I spawn the same actor but this time using code inside of an intermediate actor that is replicated. This in turn spawns the final actor that everyone will see and interact with. This system appear to work fine for replicated movement and physical interactions, but when I try to call a server side script (run on server) it fails every time it is from a client. Trying this as the server works as expected and even allows the server to run a multi cast back to clients. Im not sure where the hickup is and I noticed that their names are miss-matched from Server to client because of the pre-spawn actor that is set to replicate but was spawned via widget so it doesnt exist everywhere.
Your vehicle parts shouldn't be talking to the server
What's the idea here, visualizing a part locally first, THEN telling server to spawn it?
And what do you mean by the actor being spawned inside a widget?
Are you trying to do what I'm doing in this clip except "see" the part in 3d in the selector?
@dark edge
https://www.youtube.com/watch?v=N8tNpO0xty0
Yes I am trying to visualize it locally and telling the server - spawning inside as the code that spawns the visualizer is inside of the widget class - here is an example of the process im going for
The player needs to be able to interact with that piece to take control in this scenario
playing as the client
So when should hte server know about it, when you exit build mode?
@dark edge Once the piece is placed - the blue piece should not be seen by everyone
No it doesnt, Login is responsible for setting up the PlayerController.
Hence why its return type is APlayerController
If you are overridding Login then calling APlayerController* NewPlayerController = Super::Login(NewPlayer, InRemoteRole, Portal, Options, UniqueId, ErrorMessage); will give you the PlayerController.
i did a bit more digging and im suposed to use InitNewPlayer i belive
seems its not available on gamemode, only in gamemodebase
ummm
guess i will juse use the super like u suggested
is there any issue in this case in calling the super before the function ends?
Generally you will always want to call Super at the beginning of an overridden function. Unless you know WHY you wouldnt want to.
i tought it was at the end, guess my best practices are failling me badly
i am a bit confused, arent u suposed to be able to only be able to override functions from a parent class or is this a c++ thing?
or am i just a terrible coder
Yes. GameModeBase is the direct parent of GameMode
When i said "where ever you want" I meant more like "In any derived child"
So thats my bad
ok so, if the function "initNewPlayer" is in gamemodebase and my gamemode is derived from gamemode then i cant override it correct
You can override a virtual function in any child
Regardless of depth
Assuming its not marked final
yes but mygamemode is a child of GameMode not GameModeBase
thats my issue with overriding that function
i have no idea why it is not a child of gamemodebase tho, i started this project 3 years ago
So if InitNewPlayer is a virtual function of GameModeBase and GameModeBase is the parent of GameMode then its available to be overridden.
but isnt it the other way around?
isnt gamemodebase the child of gamemode?
🤯
ok so thats why i was so confused
so its login, initNewPlayer, postLogin
in this order?
right?
Yes
so initNewPlayer returns a FString, what exactly is it returning?
Look at the function implementation.
If everyone always gives you the answer, you wont learn how to find it yourself.
Especially when its an easy one to have answered just by reading the code.
Which, is a pretty important skill for a programmer to know how to do...
so i was taking a look at the code
and i found this somewhat amusing comment
// This is a bit odd, but there was a complex chunk of code that in the end always resulted in this, so we may as well just
// short cut it down to this. Basically we are saying spawn at 0,0,0 if we didn't find a proper player start
"i dont know what that code did but it always returned 0,0,0 so thats what im doing"

@prisma snow @rose egret Making them deterministic would be difficult as some behaviors rely on randomness. Making the randomness reliably seeded would be problematic in some cases. Not to mention the fact that some behaviors rely on surroundings, which would also have to be precisely replicated. Which at the moment they are not - I try to keep it as slim as possible and a lot of my logic is culled if out of view.
The system isn't too bad, I worked on it pretty hard and I keep all of the projectile data in one place. The projectiles themselves are really complex - the game is about spellcrafting and allows players to put a dozen behavior modifiers on a spell to change how it acts.
In order to optimize rendering and get all this info into Niagara, I've managed to pack it all into arrays, but now I need to get the arrays with positions across the network.
During testing I relied on UPROPERTY replication which I was never going to keep - but it actually worked surprisingly well. The issue is that replication of properties tries to sleep as much as it can which is awesome but in my case it causes issues. Instead of hacking around replication I thought I might as well just compress it all and send it off.
I'm not opposed to seeding projectiles in principle, the issue is that the game is sandbox and the projectile behavior is impossible to predict outside of some frame inbetweening for networking purposes
To be fair, they didn't say they don't know what the code did. Only that it was overly complex and always resulted in 0,0,0 :D
i want to belive not even unreal devs know how the engine works and everything comes out good because of magic
exept u @thin stratus cause you wrote the compendium 
@civic seal you are not supposed to have perfect projectile, anyway its multiplayer and things are different in each client, generally the real projectile in server or owning client calculates hit and damage, those in remote clients are just cosmetic.
It is purely cosmetic. The server calculates everything, I just need to let the client know "hey btw 200 projectiles are doing exactly this thing this frame"
200 projectile a frame ?
Well I'm not going to send every frame obv
I'm thinking about maybe 24fps replication
the rest is interpolated
200 is a lot if its replicated actor spawn, even using custom struct replication its still a lot
It isn't
maybe just send the fire event to client ?
It's a batched system, one actor is responsible for rendering every projectile of a certain type
for instance if you have 100 agents instead of replicating projectile data send RPC and simulate projectile in their client
I remember for my own FPS I was just sending a CastFire() RPC nothing extra
Yeah thats what I'm intending to do. I was just mentioning the possibility of maybe compressing the update before sending it out. My hope was lowkey that somebody would see what I'm trying to do and be like "no you idiot, it's done this way"
But it's not an ordinary FPS, that's why I'm dealing with such a high volume of data - I can't really just wing it
Yeah I have an idea for a global projectile system that basically uses something like that as the only input
😔 i would too if I didn't straight up just have a boids modifier for my spells
I mean if you make it as deterministic as possible it should still be doable
@civic seal did u think of compressing data by sending relative position instead of one lots of FVector ?
if you have several projectile spawn, etc from one agent of a manager , you can send one FVector as origin and the rest as in16 or less relative to origin
Thats some big brain shit right there. I should totally write that later. Have one master projectile responsible for most of the precision and a bunch of others close to it that piggyback off it
Could totally just be done as an encoding step before sending the packet out too
and THEN wrap it all up in an LZ4 archive 
LZ4 is useless I think
UE can do compression over your packet
u dont need to compress them like that
Well LZ4 from what I know uses a dictionary. So it would work drastically better if I hand it a bigger chunk of data
And its blazingly fast
I use it for my inventories when sending them to the cloud and it crunches some of that shit down from like 39KB to 6-7KB. Though granted it depends on how dense the data is
An overview of using Oodle Network to improve streaming performance for your project.
this is better than LZ4 I guess
this looks straight up arcane wtf
@rose egret thanks a whole bunch
I'm gonna give it a shot because I hate serialization actually and this looks easy to set up
thanks for the detailed context. I understand that it's a complex setup to replicate indeed.
I'd do two things (if you haven't already):
- Consider how necessary is to replicate exact locations of projectiles. As you mentioned on one of the comments, it might be only aesthetic? What is the worse case scenario if it is not replicated?
- Think how much of the projectile stuff can be "precalculated". This could mean that the server performs the projectile calculations ahead of time in a single frame and sends some compact data results (initial/final position, time to reach...).
In the worse case scenario, the projectile movement is too dependent on external factors (other projectiles for example) to be precalculated and needs a relatively high precision. In that case, need to figure out a way to replicate the positions with "high" frequency. How many projectiles can happen at once?
Don't only worry about bandwith (which is a legit concern ofc) - consider also network jitter, dropped packets, ping/lag, etc. Also, do projectiles need to be very precise timing-wise or can you tolerate some delay?
having an issue, every 1 / 5 times my client wont spawn, but its still calling the spawn function in the game mode, any ideas?
potential race condition?
Hello! Me again, apologies. I have what is probably a stupid question but worth asking. I have a small project that is now seeming to work quite nicely, built on a dedicated server model. I made it initially without any further plans for it at first, mostly to see if could. However, it's quite performant and fun so I want to extend it and release it. To that effect, I just want it to be in a situation where players would be able to host and join games themselves rather than host dedicated servers myself. So my stupid question is if there's a convenient way within code I can have the client launch and connect to a dedicated server build on the machine? Or if it's worth biting the bullet and just switching to a listen-server model? I suspect it's the latter, which I'm a bit reticent to do since it always seemed to give me issues.
Thank you! No rush on this, please feel free to reply whenever, and sorry for interrupting.
How can i trouble shoot it? this is my first project, everything was fine, didnt change anything, then suddenly having the issue today
debugging
When I'm worried about race conditions, I add a bit of a delay to certain initialisation processes to see if that fixes things. If it does, then I start to get a better idea as to what isn't ready when it should be. Then usually rather than using a begin play, I try and use something more event based so actors can notify each other that they're available.
hello, am i right in thinking you can't replicate a pointer
UPROPERTY(BlueprintReadOnly, Category = ACF)
class AACFItem* Item;
?
you can replicate a pointer to an actor that is also replicated
not sure about uobject pointers
actor pointers will get synced through a net id that is 32 bits iirc
LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_AI_Guard_01_C_2. Function SetMovesetActions will not be processed. so i see this warning
is that actor replicated?
i think the AI doesn't have a PC or something
was occasionally if they spawned at the same place, it wouldnt spawn one, but sometimes it would. just had to move the spawns into the air a bit
hi guys, is there a way to get the actor who is interacting with a widget? just like how the OtherActor node is functioning in the ActorBeginOverlap. I was hoping on how to do this on a widget.
relevancy
when i kill a player, and respawn them, i was to set all their default stats back. Should i make a function in the player state to do that? that is where the stats are stored
one main purpose of the playerstate is for storing persistent variables in case you need to respawn, possess another pawn, etc. If you want them reset you’re better off just storing them on the character.
I store all their stats, including current and max health. I was trying to reset their current health in there as well. Am i better keeping everything on there, except putting current health on the player?
i can’t speak for your other variables but it’s hard to imagine not wanting your health variable on the character
just thought itd be easier down the line when trying to get all of a players info at once. such as for inspecting a player, or a party system or something. This is my first project so still learning a lot
player state is better for stuff like score, player name, and stuff other players might need to know about. character stats and health are better on the character themself
also thinking that might be the go. Because im finding it hard to always access the playerstate
thats how im currently handling it
yeah definitely put it on the character, and health should always be set on the server
Also, what does Reliable do? one of my functions only works if its turned on, not 100% sure what it does
how would one generally handle death and respawn? im using GAS for my gameplay framework and i have the events death being called when health attribute <=0,it will called that death event and i have internal event( also blueprintinplementableevent for blueprint implementation) that do whatever like calking tiner in ui if i want a timer based respawn or button based respawn. and when that delegate is called, it will called another event called respawn and it will respawn the character..does this the way to go for this sort of setup?
Reliable will make sure its sent regardless of throttling and re-sent if the packet's dropped I think
i doubt that this is the way because i saw how others respawn and death system works but i thought this is the way to do this sort of thing..
im thinking of also in death to also clear any tags event and delegeate related to gameplay effect and clear activatableabilities.items(maybe store this kind of event ina method then call this on death event flow) then in respawn i callback all of those event and initialize back the character with having another bluprintimplementableevent for designer to use....
I have this type of physics. (Its Helicopter) When playing on client it jitters. how to fix that.
Lets say I have a health variable on the player character.
I am getting healed via a RunOnServer event.
Here comes my confusion/question about best practice:
Would I make the health variable RepNotify and in Health_RepNotify I would update the UI? The issue i ran into with this->Server doesnt have the UI so this currently results in errors.
Should I even RepNotify Health at all? I know about binding my HealthUI to the playerCharacters health variable, but Ive also seen that the bind basically fires once every 0.1 seconds or so?!
Setting up a second server distributable file so players can run their own servers is possible - however there are security issues with having a player connect to a server owned by a malicious host.
Can you switch on authority / remote and don't update the authority (server) UI?
I assume you mean inside of the OnRep_Health function?
yeah
Yeah, I did think about that. My main concern along with security is just ux. Assuming this is a game released on, say, Steam, and a few people wish to play together, I'd like to just have an option to host a game and join it. I suppose it needs to be a Listen Server model then. Worth changing over to it and fixing the issues I encountered with it before I think. Thank you!
hm, that would mean i gotta have a branch for every variable of my character i guess?! 😄 like Strength,mana,health,gold,inventoryItems etc? 😄
writing a networked game basically means writing 2x the code 🙂
Yeye, just seems weird, im watching a video on the topic right now,and he does OnRep_Health as well. imma see what his solution is,but ill keep yours in mind, and if his is better ill let you know 😄
this is probably node you want
I've been experimenting with replicating motion warping animations and I've come up with a decent way to go about it, but unsure if this is optimal. Fortunately, the CMC's root motion handling seems to do a commendable job of replicating this decently even while using BP for setup (first time I've ever been able to get decent movement-related network results in BP). If anyone has solved this in a superior way, definitely let me know, but here's a working solution for those experimenting with similar stuff in the meantime. I mention some ways to improve the system to work with Z-axis motion warping , which seems like it needs better local prediction handling via packed movement in the CMC (or a change to allow Z-movement to be applied while walking, but gravity will need to be turned off too, so you're likely going to have to do some packed movement stuff anyway for the move to be set up correctly and avoid corrections).
https://youtu.be/SgNJc7OsZNA
A simple setup to get replicated motion warping working. It seems that local client prediction works quite well, thanks to the CMC's excellent handling of root motion tasks. Some extra notes and experiments are included in the video that touch on possible ways to improve the system, particularly when it comes to Z (vertical) root motion warping,...
ye,this seems to do it. Aight i gotta change all my OnRep_Variables 😄 thanks for the help!
New "understanding" problem:
Is it correct that lets say I place a Cube in a level and then "play" the game if i would use a RunOnServer Event to destroy said cube, that it would only get destroyed on the server side, as it wasnt spawned by the Server?
In this case, how would I go about lets say chopping down trees /gathering bushes etc? Would I need to "spawn" them on the creation of the level first? that seems to be crazy 😄 😄 😄
nvm, found a tutorial for it... i tried destroying it from the actor that needs to be destroyed, wich is not allowed 🙂
hey i wanna to ask does unreal null system support voice chat ????????????/
in this window it is showing that unreal is using microphone but i can't hear any voice from another pc
i mean another instance of this game as a client
any solution for that??
Null Subsystem should support voice chat
You do have to be in a session though
Iirc it locally blocks the packages if you aren't
So if you connect via IP it won't work
@violet citrus
Ohh okay thanks
How will I know events are only called via the server?
Is the docs my only friend?
Oh but event take damage happens on the server and it has an icon?
I'm confused now
Server only events could probably use the server only icon more frequently, I agree - but really, you just need to learn it as you go.
Docs, reading the C++ code, etc...
Okay thanks
I don't see how this could stop someone from cheating
Can't the hacker just execute this event? I understand movement, but this doesn't make much sense to me
If they hack the server, sure.
But it's just the client telling the server to do something. In an actual game, you'd have additional checks on the server side.
It's just small for brevity sake.
Alright
Anyone have any ideas how to get players to go into another level toghether and wait for x amount of people to join from other servers to join into the game level kinda like a tarkov raid
Has anyone had the pleasure of getting an error like this when replicating a uobject subobject?
LogRep: Error: ReceivedBunch: Invalid replicated field 0 in MyReplicatedSubObject_C?
EDIT: Hey if you ever get this and you so happen to replicate a struct in one of those fields, with WithNetSerializer = true as a type trait, uh, make sure you do the serialization right. Turns out i've been writing too much and not reading enough.
Potentially forgot to register the field in GetLifetimeReplicatedProps? Not entirely sure what kind of error messages you generally get if you forget that.
it's all registered
It actually mentions it.
re-created the blueprint and still got the same issue
so it's not just a corrupted blueprint
Thank you for the response! It's extremely dependent on immediate context, unfortunately. A player could cast a black hole spell and the projectiles around it would get sucked into it on the server side
Delay is totally fine, I compensate for it once the packet arrives based on ping
I've had testers cast spells that duplicate and had a room filled with like 500 bouncing sawblades. ⚰️ Which is exactly the kind of insanity I want to be the attraction.
Sorry we're still on this btw, I already know the things I'm going to try out for this based on earlier convo - I spent a couple days working on optimizing beam-based spells :>
That's a pretty bad way to do networked physics
You should just sync control state and add force on tick
also you'll need to mess with your physics replication settings. they are very strict out of the box and will result in a lot of hard snaps
Client:
Input -> send controls to server, server sets replicated variables.
Everyone:
Tick -> use replicated variables to determine forces -> add forces and torques
You should be adding force every frame. Right now you're adding force every time you get an RPC, which is not necessarily every frame
So after debugging FObjectReplicator::ReceivedBunch
It does replicate the properties fine in the bunch, but then it continues in the function and reads the updated properties again?
Need refresher on getting my control pitch for FPS game sent to other clients
fixed, edited the message if someone ever gets that

ok I see
ye insanity is a nice descriptive word xD
well I spent months researching about RTS multiplayer xD so nothing wrong in taking time to solve complex problems
have you read Glenn Fiddler's articles on physics replication? I think it is a good starting point to understand the common solutions and pitfalls that this kind of problems present
random question about replication, if i want to use RPC to replicate property change, in the case of join in progress / actors becoming relevant, are those spawned actors for the client using all default class values? if so what would be a good way of getting their current server values to that client? i was thinking of having a client->server RPC with a reference to that newly relevant actor, then sending server->client RPC with the actual values back for the client to set
would this be a decent approach? are there other options? i want to use native property replication as little as possible due to the fairly large datasets i have to replicate
so far ive tried that approach and it works at smaller scales (3 clients w/ each 500 member array of stuff to replicate, one member handled per frame) but because all of the RPCs have to be reliable it seems like a recipe for disaster at scale, idk
Can anyone provide me with a good walkthrough or text documentation of how to use multiplayer? I need to package and test UE5 projects but currently I'm struggling with figuring out public servers.
Hi, question, is it possible to spawn AI that is simulated on the client and then from that client replicated to server and then to other clients? Like client behaves as authority?
I have several scenarios where this cannot be avoided, therefore i will need to do it in this was. Car AI works similar was for GTA V i believe
Download smooth sync and make that client hte owner of the object
Smoothsync will allow the owning client to move the object with authority
I haven't tested it, but I remember reading and did a quick search, have you tried setting this in the gettlifetimereplicatedprops?
DOREPLIFETIME_CONDITION_NOTIFY(Class, Array, COND_, REPNOTIFY_Always)
Namely that last bit
No worries! Here's hoping.
Oh, I have a question myself actually, for anyone that's around. I'm not used to working with Listen Servers, all my experience is with Dedicated Servers, and I'm in the process of switching a small project of mine from Dedicated to Listen. However, I'm finding a couple of issues that occur only on the listen server. The one I can't seem to figure out is that my pawn, which I move only on through a server-only RPC right now (I'll optimise it later I swear) using AddMovementInput moves increeeedibly slowly, to the point of almost not moving at all. Movement is set to replicate. I'm not really sure what or why this might be going on, and regular clients work perfectly. If anyone has any idea as to where to start digging , please give me a poke! Happy to provide more information if needed.
Is this correct way to do physics (helikopter). I'm making dedicated server game.
that can work
are you using the character movement component?
Is there a way to queue repnotify events to happen only after begin play?
I am not, I'm doing something more dastardly of using a replicated child class of floating pawn movement
. But it does work fine on dedicated servers.
Set up correctly, your game should work just fine whether dedicated, listen, client, or standalone. Show your code.
I know "Time Since Creation" branches have been used
could you elaborate a little?
I keep having replicated variables arrive before begin play and then fail because something wasn't ready and so I'm definitely interested in a robust way to handle these things
I'm sure the C++ nerds have a more performant approach
And I'm not exactly sure which type of failure you're having here
but this will solve a certain type
On clients, the "creation time" would be as soon as the object becomes net relevant, so it's common for poorly written ONREPS to wrongfully fire every time a replicated actor comes into range of a player
Ah right, but that doesn't really help for variables than only replicate once because if it is too early then it never gets run
Yea I'm just using a retry timer at this point but it seems like a miserable thing to have to do for anything that might replicate before begin play is called on client
I am having trouble setting a win condition...
From a local player controller, I cast to the GameState to run an RPC
The RPC is set to run on server
The RPCs only function is to update a Bool variable "game over"
My problem is, the server can call this RPC, but the clients cannot... I cant figure out why
Well yeah that's how the multiplayer works
You need to do your RPC through something the client owns
like the PlayerController
But then any client can say it's game over whenever they want
The server should detect when the game over and set the bool. Not just recieve the bool from a player.
What's your win condition?
or game over condition?
the win condition is doing a set number of laps around a track... which is working perfectly fine right up until the cast, so a random PC cannot win unless they complete the required distance
First screenshot is installed on my Player Controller, 2nd is on my GameState
The RaceEnded? set with notify only works if the server initiates the RPC
So essentially, a client owned Player Controller can go through this code, and the "Winner" widget pops up on their screen, but if the Server owned Player Controller does it after, they also get the "Winner" widget...
If the Server owned Player Controller initiates the RPC, the Race Ended? variable gets marked as true, and the client calls the "Race Winner Already Determined" print string.
Then just try to run the event once at BeginPlay, and once at Onrep, and put a DOONCE node on the event
so whichever occurs second, will just not go
Anybody know why this "Camera Shake" node which "does not replicate" is definitely replicating, when the server shoots, it shakes the camera of nearby clients also
Guess it needs this one instead
solved
Why cant I spawn a blueprint from the level blueprint and replicate things correctly to the clients. I assume its because the level blueprint doesn't have the correct authority?
post a pic of what you're trying to do
but generally speaking the level blueprint is useless for network communication
GameState is preferred
Hey friends! I have been banging my head against a wall for about 7 hours. Time to see if anyone has a solution.
I have 3 computers connected via LAN. Each computer is assigned a user ID. Each computer is synced via a timer in the Game Instance. Each computer is presented with a test question and stores the answer in an array specific to that player in the Game State (AnswerArrayP1, P2, P3...). However, other computers cannot access the array!? Host can only see host, client can only see host and client, same with client 2. So in other words, host cannot see client entries, and clients can not see eachother.
I have no idea why this is happening and I have tried a billion different things. My only thought is I need to save the arrays in a custom event on the Game State, rather than casting from the interface to the game state. But when I run a custom event in Game State, everything breaks or only the host is visible on all computers. Any suggestions on how to do this? This is practically my last step before I can start collecting data for my experiment, so I am hoping to wrap this up.
how are the arrays updated?
I assume those are maked as replicated to begin with, right?
Yeah they are marked as replicated. When the user hits a submit button on the interface, it casts to the game State, and updates the array in the gamestate with the answer they chose in the interface.
Just to be clear, each computer has the answers at the top of the screen to show what other users selected, except they aren’t retrieving values correctly presumably being a replication issue
I thought game states could read/write from any client, but maybe I’m wrong there
I think that your problem is the direct update in the clients game state
You have to RPC the client input/answer, validate in server, and update the game state array on the server. That will replicate on all clients and you can use onRep to react to the update (to update UI for exmple)
The RPC has to be sent by a client-owned actor
such as the player controller
Okay I’ll give this a shot in the morning! I haven’t used rpc before so this will be fun to learn I think. Thank you!
So ive made a respawn function, and a function to reset the players health. The respawn works fine, yet the reset players health on runs if its set to reliable. Is it bad to have it set as reliable? and what could cause it to only work with that?
I think this is fine. My understanding of reliable is that it is only for functions that execution order matters. So you want to use it sparingly to keep memory usage low. But I don’t understand these things super deeply myself.
Cheers. Just wanted to check as i have both functions set up very similar and was odd that one works and one doesn't
Actually think i fixed it. Just had to add a 0.1 delay from resetting the players health before i respawn them
Morning! Any ideas on how to set remote role on a C++ class? Google is not helping
Client is absorbing remote function because RemoteRole is ROLE_None
documentation shows how to check the remote role but not set
Hi. How can I achieve level change for a one player (client or server), while not disconnecting the player from the session. SeamlessTravel seems to travel everyone when server has executed it, while OpenLevel disconnects player even by adding "listen" to options.
Just having a struggle with this atm, because current level is starting to eat performance and I would like to switch game content between levels. Was using level streaming up until this point.
Or is it not possible for server to keep up with multiple levels?
Apologies, I'd fallen asleep! But yes, so I've basically done something cheeky in that I've overridden the tick component in the floating pawn movement and removed the checks for client, and it replicates quite well as a result. In the pawn, I have just a button to move forwards bound to an input action:
void ATankPawn::OnInput_Thrust(const FInputActionInstance& instance)
{
if (bIsAlive)
{
Thrust(instance.GetValue().Get<float>());
}
}
Which, as a dedicated server obviously only called on the client, but now also calls on the listen-server host now. It then calls Thrust, which is an RPC replicated to the server:
void ATankPawn::Thrust_Implementation(const float amount)
{
if (PawnMovement && HullMesh)
{
AddMovementInput(HullMesh->GetForwardVector(), amount * ThrustSpeed, true);
}
}
Now, I did realise that there's no point in sending an RPC if I'm already the Authority (I'm not even sure if it matters or if it's just like calling a normal function) and I can change that, but either way the listen-server's authority pawn doesn't move. All the proxy pawns move fine on the client and server.
One thing I'm noticing is that for the authoritative pawn, AddMovementInput is called, the value is non zero, Internal_AddMovementInput gets called on the pawn, and ControlInputVector seems to be added to, but then if I try printing out LastControlInputVector on tick, it's always a zero vector
Yeah! The benefit for me is that I don't take rotation or scale into account for my projectiles. At least not yet. Technically all they need is location and velocity to figure out how to orient
So it's just a few arrays + ID array that helps Niagara keep track of whats what
Turns out you can't, any ideas on how to fix this issue then?
I'd generally advice not to read documentation if you can read source code.
SetReplicates, SetAutonomousProxy, and CopyRemoteRoleFrom are all public function calls that change RemoteRole.
great advice, I'll start doing that and I'll try your suggestions, thanks!
Hi, is there a way to bind event dispatchers before beginplay, so they would be bind before repnotify update?
SetAutonomousProxy and bReplicates = true did it! thanks again
Nice. 😄
Maybe on PostInitProperties. But generally you just assume stuff can replicate first. So you run a update check, bind, and if the replication comes later then it can update.
What are the common events/delegates/virtual function invocations on game modes, states and sessions when server and client seamlessly travelling to a new world after starting hosting or joining a new session? I need to hide widgets when a player starts new sessions but I'm not sure where is the best place to handle this?
Hi, I have a question on how the COND_InitialOnly works. I was using it thinking that it only would replicate the component during the initial setup and the component would not replicate after that. However I am still seeing them evaluated every frame in the repgraph on insights. Does anyone know why I would to see these components continuing to be checked for replication despite them only having a single variable set to replicate as COND_InitialOnly?
This should give you pointers: https://wizardcell.com/unreal/persistent-data/#should-userwidgets-persist-seamless-travel
Because unreal engine is not enough smart to evaluate that you only have that variable and that your intention is not to replicate anything else. I mean you can still replicate actors for example at runtime through the actor channel of that component's owner/outer
can we open listen server without reloading level by using open level ? i would like to open listen server on lan and let player join it trough session (like minecraft)
Nope, at least not without a heavy engine modification
hey thanks. it looks like your article contains answers to some other questions I also have
and there is no way to join a session when a listen server is listening ?
If the listen-server is listening to connections, then connections can connect to it just fine...
and so, can we stop listening to be back as a normal client ?
You go back to a standalone mode if you open level without listening, but if you want to workaround that you can start rejecting clients in PreLogin (so you're still listening to them in real-time) or maybe destroy the beacon host
Anyone know how I can call a server event from inside a widget on a button click? I tried few different things none of them seem to be working, and from my "google research" widgets are client only so i cant call anything to the server. Any help would be much appreciated!
you access the playercontroller (usually the PlayerOwner of the widget) and send an RPC through it
and call the RPC inside my player controller?
You call it on the PC. Whether you call it from the PC is irrelevant.
it worked thanks!
Guys, I don't need replication or multicast to a reload function, right? aside from the animations of course. I'm having problems updating the ammo for the clients on C++, just want to make sure that is doable without replication
I could see reload being client only but it might introduce some potential reload hacks or something? Not sure
without thinking much about it, as long as the server checks ammo when shooting any client-side hacks would be prevented
ok guys, thanks!
Does anyone happen to know what this error might indicate?
Your actor was null
Is there a way to simulate networked players/characters without running extra client windows?
So i can damage someone if im the host, but not the client. I have my damage as Check the hit, set the damage, then call a "server damage" then a "mc server damage" which takes the actual health. Have i set it up wrong?
Post a pic
You're probably trying to ServerRPC through a non client owned actor.
You are multicasting damage?
Just out at the moment. Will post some pictures when I'm back
I thought I was ment to mc the damage so everyone knows they have lost health
Generally speaking that is replication. You'll find multicasts pretty useless while learning multiplayer. There's extremely few cases where they're actually warranted for use.
Rogey. So set health / levels and anything that changes a lot to a rep notify and scrap the mc all together
multicast is usualy usefull for visual effects i think
the way i have damage setup in my project is i just have the HP be a replicated var
when collision happens on the server from a projectile it just replicates to the client
the value that is
Would you do a damage popup as a multicast or catch the hp diminishing in a repnotify?
Hello, I feel like Im being dumb and forgetting. In C++ does Standalone call OnRep's? I know they wouldn't for listen servers because there is no remote connection but wanted to double check haha
In BP, yes, in c++, no?
I think.
I mean, c++ will never call onreps for the "server" anyway.
Right?! I feel like my memory is flawed lol
Correct. We have to manually call the OnRep function after setting the replicated property if it's locally controlled
It is...not very intuitive lol
Haha that's fair. I'm not sure how to explain it
Now that I understand the system it makes sense, but something about it is weird. Like it doesn't feel right to have to manually call the OnRep
You could have a third method, OnChange, which is called by either the server locally or the client remotely by the OnRep... if that makes you feel better lol.
Kinda what I had to do in another situation where a change produced by a setter or by PostEditChangeProperties both needed to call the same update function.
Yeah thats what I usually do, just dealing with memory blockage of if standalone runs the OnReps or not
Hey everyone,
trying to figure something out here. How does one go about adding Server Admins for a UE5 Steam Dedicated Server? and adding Kick/Ban commands?
When placing an ocean water body, it sinks my island into the ground and the water is really high up, i cant seem to lower it at all
Hi guys, I have a little trouble understanding how game mode and game state interact.
I understand game mode is not replicated to clients whereas game state is.
Does this mean I do not need to set replicate flag to variables inside game state? Or do I still need to set this flag? I assume the latter.
I also assume having replicate flag on variables in game mode will do nothing, or possibly cause errors.
Can I change a game state variable in my game mode, using blueprint communication? Or does this technically count as trying to change a replicated variable inside the game mode, and the logic will be ignored? I suspect this is the problem I am running into that is giving me null errors.
If this latter point is as I suspect, could I bypass the issue by calling an event/interface/function in my game state from my game mode, and set the variables inside the game state?
Anything that is replicated will need the Replicated tag if you want those properties to also be replicated.
You can change anything on the server and, if that property is replicated and the actor/object it is on is also replicated, then the property will be replicated.
It doesn't matter what does the actual changes.
ok, thank you.
If you're trying to replicate a reference to an actor, say, that actor has to, itself, be replicated or the the client won't know what the server is referring to.
i got some bugs on a Client's side, so how to get Player Index correctly?
Player Index is not used in networking. It's only used in LocalCoop.
thank you
when i want to switch pawn, my Client do not destroy old Actor, and do not Posses new, just create an Actors, invisible for other
but for Listen server all is working fine
so, if this is not an Index, where i need to look at?
GameplayCues are good for the damage popups if you're using GAS. Not sure how that would scale in a massive game though. Without it, I dunno. Initially I like the counting damage tags that if you hit the person again within a certain time it'll stack the damage, so OnRep would work fine for that. If you specifically want individual damage events for every single possible damage source, you'd need multicasts to avoid cases where the same replication span causes overlaps and only sends one event. Also depends on game though. Turn based game has wildly different timing constraints than a fast paced shooter or RTS.
