#multiplayer
1 messages · Page 731 of 1
ok so i found something
its only that character class
every new character class works fine
already have it set to that
Are you spawning your AI, or they are placed in the level?
placed in the level
Hmm then there must be something else you messed with in that class
its probably because of something in cpp
prise the lord
i got it
had to remove getlifetimereplicatedprops function from the class altough it was not used
when I use the "event on post login" node it doesn't use the player controller I created for the players. Is there any way I can make use it?
Doesn't use the reference or the class?
I'm trying to spawn in the players and I'm using the "content examples" map from UE to spawn my players over a network. It uses the "event post login". I copied the entire thing but when I plug the possess node's player controller reference to the on post login's player controller reference. It uses the default player controller. I know it is because it ain't using the camera I set up using the player controller I created.
Did you set the right class in the game mode?
You're going to have to send code. I am unfamiliar with the example you are referring to. Sounds weird that you are manually calling post login.
this is what I used from the content examples
this is the camera that all the players are using. It uses the player controller array.
I tried another way to set up a spawning system but the issue I had was that the default player controller for local has an index but I need it for network
Hello, I´m following the blueprint multiplayer tut from epic. Do I need steam or such online services to host a game? or when I just host from the packaged app does someone find the game without anything?
@twin juniper What is the controller class you have for your gamemode?
No. You can host a game just fine. People connecting or not depends on your router. The easiest way is to use a service like Steam though.
@twin juniper That doesn't tell me anything. Show me.
oh okay thats great thank you man.
You can do port forwarding and all that jazz, or have your own rely server.
I just took a screenshot of the whole gamemode
also, that is the other spawn system that only works for local
You are overriding the wrong function
Override HandleStartingNewPlayer as there the pawn gets spawned
Also override FindPlayerStart and don't do the PlayerStart logic in there
don't do the player start in the gamemode?
It's already in GameMode
The function is called FindPlayerStart
Find it, override it
If you don't like the default behavior
Also OnPostLogin won't get called in case of a seamless travel
gotcha
so, I can find player start and just set the tags up like that, but I see the HandleStartingNewPlayer has the same issue as OnPostLogin. It has the player controller reference but it's not referencing the player controller I created
It works out fine and all I can control my pawns but the camera I set up for all the player controllers doesn't work
so, I'm assuming they aren't getting the right player controller reference
do you know why? I can control my pawns no problem but it doesn't assign them the camera.
How do you know this is the case? Did you debug and watch variables?
Print their names?
I'm not sure what do you mean by assigning camera
All I see is this function, but no where where it's called
hmmmm, you could be right because I'm just using an educated guess with everything is here. So, I do apologize if I'm coming off like a jerk.
but this function is my camera in the gamestate
now, without that handingnewplayer and onpostlogin it works normally
No it's okay. Thought you had a proof, as it can't be the case
Good now show me how you call it
I'm wondering too how someone can pass an array to SetViewTargetWithBlend?
Hello?
well, in netmode that's the only way it works
Idk why
but that's the only way I can setup a camera to be useable by everyone
sorry I was getting the screenshot for you
Ok too many issues here:
- GetAllActorsOfClass PlayerControllers I would not use for the simple reason that this array is already there. It's called PlayerArray. It's an array of PlayerStates. You GetOwner on each reference to get the PlayerController.
- Widgets are client side only. You created them without caring where they are created. You saved a replicated reference to them which is again incorrect as they are client side. Also they are created in the wrong place. GameState isn't a player specific class. Usually player classes are the one who spawn them, eg, PlayerController/PlayerState...
Also this function would only get called for the first reference in the array as you are not looping over elements
Find the compendium in this channel pinned messages and read it a few times
gotcha boss
And try to to use less GetAllActorsOfClass, as usually there are other ways to get the actors
what other ways are there?
Also you don't need to cache all the references from the start
From PlayerArray I can get everything
Also using this way you are prone to issues where some actor hasn't yet loaded when GameState loaded
So it's not counted in
I thought the only way to communicate between two Blueprints is to use that
PlayerArray gets auto managed for you
That's not correct
really?
I wouldn't have any of this logic in there
I know casting is another way to communicate but it's costly too right?
Yes. Why would the GameState speak for the PlayerCharacter when the character is the one communicating with some actor on the map
Casting is something else. And it depends
How much hard references you have and so
I would cast to the base engine classes when I can
And not cast to custom ones
And casting is usually fast
O(1)
ooooooh
But it's costy on memory in case of too much hard references
Read the compendium and learn to use each class for it's job
Putting everything in the GameState is a sign of a bad code structure
sup. i've got a light in the world that has a blueprint on it that calculates how it should move. i want to move it to server-side but i don't see anything about replication on the actor itself. my thoughts were to put the rotation on the gamestate and then replicate that gamestate to all clients every so often. is there a better way to do this?
i guess like, is it possible to replicate directional lights?
just mark the actor as replicated, there's no reason to be using the game state for this
Wondering why they hide the Replication category? Is it discouraged to replicate the actor itself?
¯_(ツ)_/¯
you can just make your own actor that has a light component though
don't even need to replicate the light component, just the actor
Hello, im trying to get my visibility for a skeletal mesh thats part of the player mesh to be random. But unfortunately in game everyone sees the visibility differently. How to synchronize this in multiplayer? ( i call the function in my begin play in my player character)
heyy thank you for that tutorial i tried following it using this method, but unfortunately does not work, the armor mesh is visible for one client and not visible for another client
or did i do something wrong in the function? let me try doing the random bool inside the on rep
What actor is ArmorMesh attached to?
That has nothing to do with it. And it would result in inconsistent behavior
the armormesh is just an additional mesh on my main player mesh which i used SetMasterPoseComponent in the construction script with .
I just tested it as I was not sure if it had to do with SetMasterPose or the ConstructionScript and it works like a charm
Not sure what you doing really as there is nothing special about it
im not sure either what im doing wrong D:
i got it to work i think
turned it into this and it works now
Hey guys, i have some niagara particles in an animation notify, i play the animation for the first person mesh localy then do a multicast for the 3rd person mesh so that the other players can see, the issue is that my particles are playing twice localy, one in the 1st person mesh and another one in the third person and i was wondering if theres anything already built in UE that blocks that so that it only plays once?
I think that essentialy it would be like a multicast that runs on everyone except the client that sent it
Hey is there any way to specify with which map a server should start by default? I have a collection of maps and everytime I startup a server I'd like to be able to add a command line argument or something to have them startup from a specific map.
At the end of the game I'm doing unpossess on all controls (so that all characters stop moving and it says "Game over" etc...), but if the player is holding down a movement at the time of unpossess then the movement continues on clients (not server), so if you were holding forward the character just keeps moving forward despite being unpossess....is there something i should do before or after unpossess in order to kill all existing movement?
Doing this seems to work, does that look correct?
Why can possibly Actor has NerDriver, but NetConnection is null? Maybe i should turn on/off something
or maybe not every Actor has NetConnection
Hello! Does anyone have any idea as to why the values aren't replicating correctly?
Well you're not guaranteed to receive every change to a replicated property so that's going to be a problem in the future if it isn't already
Recoil is usually calculated client-side, things happen too quickly for it to be networked
Yeah that's what I'm doing, you can see in the video that the first 5 bullets the recoil is based on controller yaw and pitch input, then it switches to crosshair deviation. The issue is that the server is the one that creates the line trace, so I need to send the correct coordinates to it
You've got replicated properties there though
Yes, I'm sending the coordinates to the server, setting it there
Or should I just make it locally and only send the final result to the server when I need to create the line trace?
Also, what you're seeing is without network emulation, so shouldn't reliability not be thing at the moment?
Indeed, I checked the reliable check, and it worked as I want
What would happen on a high ping since I used reliable RPC?
Answered myself, even on average ping it stops working again lol
I think client prediction and non-reliable replication should work the best here
Generally when you shoot a weapon and it's hit-scan all you do is send the origin and direction to the Server, that's enough for the server to do it's line-trace etc.
And usually it's reliable, you don't want player shots to be dropped since they're pretty critical to gameplay
Any RPC/property update will be affected by ping/packet loss etc.
But in the case above you have replicated properties, which to me implies the recoil parameters are being replicated by the Server - which is not going to work
Alright, let me change it back to the client level, and see what happens
How does client prediction work? I understand the concept, but I don't get it in practice, is it just setting the variable on the client side, then sending a call to the server too?
I don't actually know, I imagine it can get arbitrarily sophisticated. If you use the gameplay ability system it will handle client prediction for you :D
Do you know any guides for it?
Gameplay ability system and it's client side prediction
There is nothing to learn about its client side prediction afaik it just does it for you
ah kk, I guess I'll just search for a guide on youtube
And if all you're hoping to do is make a lightweight game and implement recoil then GAS might be a bit overkill but ill link you some resources
I'm recreating CS:GO on unreal, you can check server from my profile
Thank you 🙂
Just for fun?
Yeah, I started it since my internship uses unreal engine, but I might actually change CS:GO trademark and assets with original stuff and publish it
F2P
yeah I know, but it's riddled with cheaters lol
Anyways, this won't replace the true CS:GO
But it might be a casual game someone might pick up when they're bored of the original one
Unfortunately cheating is nigh impossible to prevent in csgo
Yeah of course
Good luck with your game
Thanks 🙂
I have a struct with ReplicatedUsing and COND_OwnerOnly but its executing the onrep function on client side not server in blueprints(didnt check in c++), the OnRep function is BlueprintNativeEvent, what am i doing wrong?
C++ OnReps never execute on the Server
BP on reps are a hack which is why they do, even though they shouldn't
If you want the Server to run the same code, just call the function manually when you change the variable.
For some reason i remember being told the opposite, thanks for correcting my memory
@chrome bay It worked! I set the coordinates client side and made a reliable RPC for the line trace only. Thank you 😄
Im basing all my animations on the ai state which is stored in an enum in the ai controller. Problem now is that the client side cant get the state of the ai since the controller only exists on the server. Does someone know a workaround for that?
this code is in the anim class event graph
replicate the data in Pawn or replicate AIControllers
either way will work, only second one is not recommended as it adds replicated Actors
so basically for replicating the data in the pawn i would need to create another variable which stores it and is replicated right?
yes
ok
Hello, how do i mirror an action in multiplayer? For example, two players are facing each other. Player 1 spawns a cube on his left side. Player 2 would see this cube on his right side normaly, but i want him to see the spawned cube for him on the left side too.
not sure why you would do that, but instead of replicating the cube actor you would spawn the actor only locally and would replicate the action. How ever this means that you either need to have a cache of cubes to be replicated in order to have the cube spawned on other peers if they join in later or you don't care.
But to be faire I'm not sure what you are trying to do, but if it involves gameplay I would replicate the actors position properly as it otherwise results in 2 different representations of a world.
what im trying to do is like in card games, where for all players the map looks the same only that the other player is always on top or the left side.
I see, then just replicate the data, for example if it would be like a card game take an array and this represents the cards from left to right (index 0 -> N) then you can position them where ever you want.
Thought about that too but couldn't find a way hot to work with that replicated data yet, maybe i was missing something.
Well you need to know when smth changed and then apply this change to your visual representation.
Yeah, lets say i spawn a cube. Thats the moment something changes. So i don't replicate the cube, just the data where he is.
How does the other player know that this cube was spawned on this location? I guess because of a RepNotify for the location part. But how do i tell the other player to start an "event" to create his own cube at that location for his view. Or do i understand something wrong right now^^
No, your system would do smth like Play Card, this would add an instance of CardData into an array for example. Now you have two ways.
PlayCard is a replicated function that will spawn smth according to the parameterrs.
The replication of the array will make you check that an new element was added and this PlayCard is a local function, that will spawn the actor on the one peer calling this function, and the replication will trigger the same logic based on the data given in that array
Is there an easy to replicate material parameters? On my characters I have a staticmesh cylinder below them with a material that has a color parameter, when I spawn the character it on the server I set the color on the material. But when clients join they don't see the color change...Even though I had set the replicate component on the staticmesh, i have set replicate on the variable that sets the color etc...
If i understand you right, i spawn a card and that card i add to a replicated array. Because that array gets changed the other players get a "notification" that something has changed in that array and calls a function to do something with the information in that array?
No the actor it self is not relevant. the actor is just the visual representation of your card and is not replicated in any way.
Let's say you have smth like this:
USTRUCT()
struct FGameCard
{
UPROPERTY()
UMyCardData* CardData; // Comes from a data asset for example
UPROPERTY()
ECardRotation Rotation; // Vertical / horizontal, facing up or backfacing
};
Then you have an array TArrray<FGameCard> PlayedCards which you can replicate. and depdending on the content of this array each peer can spawn actors. What needs to be spawnd comes from the data object that is loaded from disc
Yes, don't replicate it. Better have some struct with "player colors" and replicate this and then just apply these colors 😉
I'm not following? How does a struct help with this? Note that the characters get spawn in by the server before the client has joined. So when the server spawns the character, it sets the color; when the client joins it doesn't see the color update. If I manually update the color on the client then it works; but it should just replicate the material from the start
You replicate the struct and then you can take the colors from the struct, you just need to init this struct with the right values that you want to apply to your material
I still don't understand why a replicated struct would be any different from a replicated linear color? When the server spawns the character it generates a random color (say "Blue" for example) and then set a replicated "TheColor" variable on the character as that blue. It then updates the material paramater with that color from the variable.
Repnotify whatever you need on client to get things setup right
The client is not in the game yetat that point though
Repnotify will fire when they join
because it's cheaper and easier to replicate a struct than some UObject instance^^
Linear color is a struct
Oh i see, so if i update a variable which is repnotify then as soon as a client joins is will run any repnotifys which have been done before hand?
no it will only call rep notify if it replicated smth. it's a notification that you received a change
and IIRC you can be sure that you have received the first values in the actors BeginPlay so if the color doesn't change you can just grab it there.
Ya
That's what's so great about repnotify
Yup that did it thanks
Same thing with entering relevency range
Ok, i think i get what you mean. Lets say the first entry in this array has its location variables on the middle bottom and this ward belongs to player 1. So he spawns an actor with all the fata from the strict on that position. Would the other player not do the same?
Let's assume we have smth like this
+-+-+-+
|2|1|0|
+-+-+-+
|0|1|2|
+-+-+-+
where the numbers are indices.
then you have two arrays
TArray<FCard> Player1Cards;
TArray<FCard> Player2Cards;
The cards them self don't know where they are, this doesn't matter. If the array has at some index a valid object you can spawn smth for it. If it doesn't you keep the slot empty.
where you place the stuff is then fully up to the peer. It will calculate it based on the position (index) in the array
Would i not need to tell which array goes on on top or bottom indices?
this is just an example. you can do what ever you want. but it allows you to use indices to specify what belongs in which slot.
you also wouldn't have two arrays like this, you would have one array per player and the "local" player would put it's array always on the bottom for example and the other player would be put on top
Sorry if i understand something wrong but if i do it like this. Wouldn't i trade the problem from the location to a problem of setting which player card array gehts on which location?
Well no, as you always know: Local player stuff goes there, remote player stuff goes there
at somepoint you need to specify locations anyway, but this way you always have a context for your decision
So in text:" is this array local put it here if not put it there"
sigh
i have delayed this for well over a month now
its time to get started on interpolation
anyone got a good guide/starting point?
In what context?
Are you using character movement component?
yes
when you start and stop moving
like in the period between you starting moving and reaching the max speed
same goes for stopping
Are you changing max speed at runtime?
nope
Are you doing anything weird or outside of
Input -> Add Movement Input
?
nope
Show a video clip with the capsule visible
the last time i change it is in the constructor
give me a hot minute
cpp only project or are you blueprinting your character class?
also isnt interpolation supposed to be a fix for rubberbanding
You should first check if a BP character deriving from the engine-provided class behaves the same.
You might be screwing something up like client and server disagreeing on acceleration or whatever
just whip up a BP character and give it the same speed and acceleration stats and see what happens
this is
weird
the rubberbanding suddenly isnt happening anymore
wait lemme check one more time
Thanks for your help, still have no clue how this should work🤣
You can either have the player cameras oriented opposite OR just replicate the needed data and have each client interpret it differently
Specifically what are you trying to do?
Thought this may be a better place to ask
Subsystems can't replicate with any real world use right?
For a "manager" or singleton, am I better off just using an actor?
Or chucking everything into something like GameState?
Or is there a better alternative?
I think people are having the subsystem spawn an actor to replicate through
ah interesting
All i want that the cards from each player are shows at the bottom and the cards from the other player on the top. Waht i understand is that i need to replicated my data for the cards and let each player place the cards for himself. What i don't get is how i access the replicated variables fromthe other player.
Do you necessarily want a player to know another player's cards or just the ones they play?
For now, just let then know the cards, so make a few replicated variables on their PlayerState or Pawn like
DeckCardArray
HandCardArray
I only want them to be visible at the top
I'm talking in a cheating context. But that's for later
In that context would only when he plays the cards know what it is.
So for now your goal should be to sync each players card arrays and have each local machine show local players cards in one spot and other player's in the other
Yeah but where do i get the Variables from the other players? For my local no problem. But how do i use an array that when i make my blueprints don't know about because the other player sands me them when the game is running? How do i access that array from the other player so i can that his cards to that location?
Replicated variable on PlayerState is where I'd do it
Playerstate
-HandCardArray(repnotify)
So i make for each player a handcardarray and when the round starts i call that repnotify?
idk what a handicap is
repnotify will fire whenever the array changes
that's when you'd move cards, etc
Sorry my smartphone doesn't know what englisch is and is changing some words
And how do i know of that array from the other player at start? Clothing changes at the start of a round
Repnotify
just hook into the repnotify and it'll work
RepNotify fires every time the variable is updated, even the first time (right when you join)
Thx i will try that
Is the server a player when Doing listening servers?
Im trying to make world transitions that wont cause client disconnects in an online session. I started learning about level streaming and I've just discovered the AGameModeBase::bUseSeamlessTravel. It seems like they both do the same thing, except level streaming uses sublevels. How should I choose which one to use?
yes, listen servers act as both a server and a client simultaneously
Thanks, I see now
Does anyone have a simple breakdown as to how you would have an actor handle the replication on a subsystem?
I dont think a subsystem can replicate any properties, but it could feed data into a replicated actor
I haven't done it yet but something like subsystem spawns actor based on world netmode and actor registers itself on clients to their subsystem??
does a subystsem even have a netmode?
They are UObjects iirc
Cause I think all of their respective parents are also UObjects
GameInstance, World
LocalPlayer
So usually they don't replicate anything. If you need something to exist on both ends you can just use it's BeginPlay to register in the Subsystem
And EndPlay then to unregister
Aka, add and remove to and from array
Does a subsystem seem like a good fit for something like a global projectile system or would that maybe work better as a component on GameState?
I hope we are talking about Gameplay Subsystem
Honestly, Subsystems usually hold the same type of code that their parent would usually hold
Just encapsuled
If you wouldn't put it into a UGameInstance, you wouldn't put it into a UGameInstanceSubsystem
UWorldSubsystem gives you something more generic in the scope of the World
If you were to make a global projectile system with projectiles as just raw data, where would you put it?
So you could make that a Projectile Pool or so if you want
Just
Tick -> foreach ProjectileStruct -> update
You could, there is just not replication in it

Okay still a bit confused then
is it
Subsystem spawns an actor that actually holds the replicated data?
And the subsystem just performs actions, and retrieves data from the actor?
If you need replication it's probably better on a replicated actor of sorts
didn't mean to reply there. more of a general question
Yeah basically the subsystem does net stuff through the actor, but then it begs the question, why isn't this all just wrapped up in that actor instead.
🤷♂️
yeah just seems like I'd be writing the same code twice. once on the subsystem, and once on the actor
Or at least writing two functions, one to pass onto the other
Yeah, I have also made a gamestate component that acts like a subsystem but has replicated properties
Yeah that's what I did before subsystems. I guess I'm just a sucker for
Get MySubsystem -> do thing
yeah, so maybe a GameState component to act as a singleton is a better pattern?
I think it's up in the air really, do whatever floats the boat
Literally in my case, got a BuoyancySubsystem lol
Or rather, FluidDynamicsSubsystem, it does global buoyancy and drag for water and air.
arlighty. thanks for the input. let me play around with it a bit and see what happens
Can anyone explain the differences between level streaming and seamless travel?
They're fairly unrelated things
Level streaming = load/unload part of the current level
Seamless travel = once connected to a remote server to play online, change level on the client without a giant blocking loading screen
okay, that makes sense. I was adding other worlds into the persistent level as sublevels, so it seemed like just another system to transition between worlds.
So it seems like I could use both to accomplish the same thing
Why would I choose one over the other?
Any way to connect to a remote server without a giant blocking loading screen?
hi, in an experimental RTS I use behavior tree to move my units. As long as I send move command to server everything works, but the unit movement is not smooth. Controller doesn't exist for my unit (actor) on client, neither does behavior tree. So how to calculate movement on the client and get movement done smoothly?
None
You will use seamless travel for changing levels (and reinitializing game mode, game state, etc) in a multiplayer game
Level streaming is more commonly used for bringing up and down parts of a large single player level
Oh okay, thank you for explaining it to me
btw for those interested today I posted a new article about how to implement a better synced clock in a non destructive manner
can find it in pinned comments in this channel
let me put it the other way... how to sync client with server, when there is no controller on client's actor present to do the behavior tree logic?
The behavior tree logic is done on the server and that gets replicated
hi, thx, yes I get that part and it works well, but actor's movement on client seems to be out of sync - it's not smooth. So client needs to do its calculations on its own and only get corrected by server from time to time
You don't sync the brain, you sync the body

am having an issue where I spawn a moving rock , on hit its supposed to cast to third person character, but the casting always fails, the casting actually works with an AI but not multiplayer, any help is appreciated
Why are you destroying self when you still have stuff left to do.
yea makes sense, i will fix that
That's some seriously deep life advice right there.
i've a replication issue with my client character where he shoot on the Y axis / play sounds through some function, server hears the sound and also is able to shoot on the Y axis, any help here?
Can you share a screenshot of the blueprint?
ignore the comment, a bit outdated on what the bp is supposed t odo
so basically i can get linetrace working on any axis when i'm on the server, but for some reason the client cannot access the Y axis and just shoots on the x axis. the other issue i've got is that the sound does not play clientside either, but plays on server and i'm not sure why. for reference, this is being called through an event dispatch that looks like this
'on use item' is the event dispatcher
then it's used here after the sphere collides with the player and it attaches the gun to a socket
which takes us back to here
Bruh that is all over the place
yeah...
i've attempted this a couple times before and gave up, this is my third attempt haha
so basically right now, your setup will do nothing on the clients computer until ping ms later
Do your projectiles do anything fancy like bounce or curve or are they just bullets?
no projectiles, just hitscan
ok so I'd do it like this. You can do it all in the weapon if you set the owner of the weapon to the pawn that equips it.
Pawn
Input -> Get Weapon -> Call Fire
Weapon
Fire -> Hitscan -> Run on Server Event
Run on Server Event -> double check hitscan if you want but ignore this for now -> Do replicated stuff (apply dmg, etc).
That's basically clientside hit detection
OR if it's super slow paced and some lag isn't the end of the world
Pawn
Input -> Get Weapon -> Call Fire
Weapon
Fire -> Run on Server Event
Run on Server Event -> Multicast Event
Multicast Event -> Hitscan -> Do Cosmetics -> Switch has authority -> Do replicated stuff (apply dmg, etc).
not sure how setting owner works, is that about all i've got to do in that regard
i'll probably go with this, im trying to make a competitive shooter haha
You should be doing Equip on the server so whenever you Equip you'd set the owner
You aren't gonna make a competitive shooter with BP only
At least, not one that can't be cheated at trivially
well, just trying to get to the mvp stage
But if that's not an issue, do the clientside hit registration if it must be snappy
Basically it goes like
Hey Mr. Server, I hit that guy
OK Mr. Client, I'll let evryone know.
With optionally, the server double checking to make sure you're not talking out your ass.
If you're doing a competitive shooter, it definitely isn't "optional" to have the server verify the shot was even possible.
You're already waiting ping ms at this point
then i go to here with the fire and then it's the hitscan after that
Well yeah but you gotta make it work before you make it bulletproof
im trying to make a competitive shooter haha
Why I was responding
All of my games are co-op, so I just do client hit detection 😅
cool, will keep that in mind
ah i see what you're saying
because it gets replicated right?
i think i need to do that though because it goes from the character BP to the gun BP, doesn't replicate without that for some reason
Yeah. To start with, do clientside hit reg
Input -> Do shot + cosmetics -> Tell server about shot -> Server updates replicated values -> Server tells everyone but you to do cosmetics
or atleast, i don't know how to replicate the shot without it haha
Start by making a run on server event in the GUN that passes over info (hit result at least)
How do you do that last part "server tells everyone but you to do cosmetics".
gotcha, will try doing that
I think there's a multicast skip owner, or you can just check if owning client on the recieving end of that multicast and bail out
ahh okay
Welcome to the toughest part of making a game, making the damn thing work in MP without lag all over the place.
Making it work without visible lag and with server authority is even harder
since i started trying to do game development, i've come to appreciate what other developers do in regards to multiplayer replication, i am absolutely lost in this part haha
Then maybe don't start with a competitive shooter unless grinding away for years is your style.
it's a way to learn
well, prior to this i've done some single player stuff
I've done this stuff for like 8 years and I wouldn't want to try a competitive shooter. Although I am trying to do multiplayer vehicular combat with projectiles so I'm a glutton for punishment too I guess.
just a singleplayer fps where u shoot bots running at u
I'm lucky in that I don't need prediction as my vehicles are fairly slow responding.
you send the input to the server?
Only let people get in a vehicle if their ping is < 10ms. Problem solved. Easy.
my vehicles are client authorative with some server validations lol
well shit, seems like as soon as i just did this
it started working lol
Mine are fully designed and built at runtime so yeah, don't wanna go down that road lol
both ways are a PITA, vehicles, in general, are a PITA
specially when you have multiple players with vehicles
i think now the issue i may potentially have is with damage, the gun at the moment just does knockback and i was just trying to get that working at the very least
yeah the whole input thing
As far as neworking goes I just replicate control variable state and physics and it just works.
Sure you wait 30ms to turn but it's a bigass tank, you're gonna wait 30ms to turn anyway
ye
Although stuff like this is possible so who knows if lag will be a huge issue
Very old video but I found it when trying to track down my dedicated server testing videos.
15,000 hp awd bike with a propeller shoving it into the ground makes for some broken necks
that looks fun as hell
Why would i ever want to set a variable as UPROPERTY(Replicated) when i can just change it on server through a RPC?
Stateful
What if you joined a game late
Say you have a room with a light switch. The switch is off by default and there's an RPC to turn it on. Player A walks into the room and turns it on. The light is on and both Players A and B see that its on. Great.
Now Player C joins the session and enters the room. The light is off for Player C because its still using the default value because the RPC happened before the were in the session.
You missed the RPC, what is your variables value?
There's other reasons too, like an RPC can just simply get dropped due to packet loss. But a replicated variable should update (eventually).
But then its not perfect either, the custom event that runs on the server to set the replicated light switch bool to True might get dropped due to packet loss and so it never changes in the first place.
Reliable my dude
You can use reliable, but then I've heard that also has the potential to overflow and cause clients to disconnect
Well yeah if you send tick input reliable
SendAimDirection should not be reliable. Interact() should be.
So maybe only use reliable for things that have to absolutely work no matter what, such as ending the round in a cs go match or something.
That should be a repnotify on GameState probably
Anything transient and important
Something that happens not often but MUST happen for the gameplay logic to even work.
So if Jump is reliable and there's 10 players all jumping up and down isn't that enough to cause an overflow?
I guess it depends and is worth testing.
10 x 1 x 5/sec is like 50 bytes a second
I mean there's overhead but its not like sending 10 vectors every frame
Fortnite burns about 15 kB/sec so 50/15,000 is like 0.3% of your bandwidth
So like nothing
good to know
While sending just 1 vector a frame is like 700 byte/sec
am having an issue where I spawn a moving rock , on hit its supposed to cast to third person character, but the casting always fails, the casting actually works with an AI but not multiplayer, any help is appreciated
You destroy self before doing stuff
do that last
Not saying that is your problem but thats A problem
That's your problem
What are you trying to do here?
why are you doing clientside hit detection for this
The player is throwing a rock, when the rock hits another actor or player, i want that actor to play a knockdown animation
event hit is only local?
Pass the hit struct over in the Run On Server event.
if you want clientside hit detection
OR only do it on the server
either/or
you either need to gate by LocallyControlled or Authority after Event Hit. If you do serverside hit detection you don't need any RPC .
this is what i did but casting is still failing on client and server side
9 times out of 10 there's a way to avoid casting
Print the hit actor's display name
make sure it's actually hitting what you think it's hitting
hmm really
k
Maybe you can use an interface, an event dispatcher or you can use tags.
I like to use tags because its already built into the default Actor class. I just tag my actors as needed, "Enemy, Destructible" for example. Then during an overlap event or hit result, I can use the actorHasTag node to check for any tag(s) I want and do stuff to the actor after knowing that its the right one without having to cast. Ex: Projectile hits something, break hit result, get hit actor from hit result, if actor has tag "Destructible" then run custom event that does stuff without having to cast.
weirdly it saying am hitting the rock, not sure why, but when i tried casting to an AI it worked
or you could use an interface and do it that way, also works well
yea i would need to learn that
Aren't you supposed to be hitting a character?
is the rock a character?
no
Dude your naming convention is mega confusing. WHy is all this called RockSpawn, when you don't spawn a rock
yea good point, i spawn it in my character BP, bad name
How many do you spawn?
@dark edge it looks like my rock has an hit event even when it doesnt hit anything, am thinking the server rock is colliding with the local rock, is that possible (even tho the server rock is invisible from local side)? if so that would explain why the name of the actor printed was my rock
its just one rock
If it's a replicated actor then yeah it's totally possible
why are you spawning 2 rocks
Show how you're spawning it
the top one is the local side (it also fires of the server side)
also strange because my other rock projectile doesnt have collision problems
What the spaghet is going on here
lol
This is gonna take a minute
Why are you doing all this local/server stuff, you're not gonna have prediction anyway
why not just input -> server -> do replicated stuff
idk, was just following guide 
Do you have a base ability or is every ability a big pile of wires like this?
btw how would i execute some code on the server without invoking an RPC
Is this hard coded into Character?
You wouldn't
The only way info goes from client to server is with RPCs
the first rock fires off an event hit mid air, the second rock later on acts normal, so very confusing
So are you spawning 2 rocks or 1 replicated rock?
i dont think so, you mean the replication stuff? no not really, i just started it, if you mean the abilities, yea i have been programming it like that for a while
a replicated rock and a local rock
They are probably colliding
yea, i spawn the rock for the server side but it wasnt showing for the client so i spawned it locally as well
How many abilities are you planning?
7 but only 2 needs casting i believe, the other one casted fine, am guessing since it just a capsule trace inside the same third person BP
No no i dont mean sharing info between server and client, just running some generic code on the server
something like changing a map completely after a certain amount of time regardless of what the client(s) do
would a HasAuthority() check in the gamemode code suffice?
Yeah the server is running the engine like any other
HasAuthority means you're the boss, either server or standalone or clientside authority stuff (i think)
epic
There’s no reason to use HasAuthority for the GameMode because it only exists on the server 😄
Say you had a replicated actor, which would be most things in your game except HUD/UI or GameMode. You'd gate stuff by HasAuthority if you want it to only do something on the server, and it could possible happen on any machine. Like hit detection.
So you’d pretty much want to always use hasAuthority when doing onBeginOverlap?
Say the character steps onto a floor switch that opens up a trap door.
Depends on if you want local prediction or not I suppose.
It would be something like TrapDoor->onBeginOverlap->hasAuthority->overlappingActor is character…
That would work because the TrapDoor and it’s switch are level actors and not possessed by a real player. Right?
Yeah you might move the gate so cosmetics happen locally but yeah
Every replicated actor exists in multiple worlds at a time (servers and other ppls)
Yea
Like maybe you show the trap slamming shut and play sound and spawn particles on overlap, but gate by HasAuthority before applying damage. Or don't, if you have some damage prediction setup. Depends.
If you gated right after overlap, you'd have to replicate the state of the trap or some event to do the cosmetics
Anyone know where Lyra's EOS handling is located? Trying to find and emulate how they handle hosting and joining.
Looks like it's in CommonUser instead of OnlineSubsystemEOS 😄
Hello, guys, I'm trying to spawn multiple players with spawn actor node. I don't have any issue with the location, but the rotation is working only for the server. I'm using the gamemode for spawn them
Hi guys, any idea why when i'm doing rpc call from client to server with scene component variable, scene component variable is okay on client, but on server it seems to be null (display name is blank)
Other variables seems to replicate just fine
IS valid node on server returns false
its not part of the Actor CDO and not replicated?
or its a component on a non-replicated Actor that has been spawned in runtime
either way, Component doesn't need to be replicated to be net addressable
it requires that A - its owner Actor is net addressable and B - Component is either stably named (so a Component not added in runtime) or that Component is replicated
for Actor to be net addressable it needs to be either loaded from level, replicated, or deterministically named on all machines with IsFullNameStableForNetworking returning true
(third condition is how actors loaded from level are net addressable by default - their names are serialized with the Level and IsFullNameStableForNetworking returns true if Actor has RF_WasLoaded flag)
@winged badger Thanks a lot for very detailed answer.
The variable that doesn't get replicated is in fact static mesh, spawned in component via actor's construction script.
Actor is replicated.
Even tho I have added set is replicated node in construction script, it didn't help, but I'll have to debug it a little bit more 🙂
Appreciate your help dude, thx.
you can replicate a pointer to the Actor and then have each machine just access its local non net addressable component from there
Is it doable via blueprints? How do I do that then? Even tho, I'd like to resolve the problem that I have first, just to understand what's going on here.
instead of sending ValveComponent you send ManualSteer reference and then you do ManualSteer->ValveComponent on the other side
this wouldn't work if you had an array of Components and didn't know which of the Actor's Components you need, but in your case it will work just fine
That's a way to workaround this, but unfortunately in my case, I send scene component, because I can push there static meshes from many places, and I need to know specific static mesh. If I had there manual steer, I wouldn't know which specific mesh did I send
is a listen server automatically replicating actors?
What do you mean exactly?
you can send a reference to a StaticMesh asset just fine, your problem is StaticMeshComponent ref
I meant StaticMeshComponent
you can deterministically name them when you spawn them
and use SetNetAddressable(true)
I guess that have to be done in c++?
by name them i don't mean variable name, but what you'd normally see in outliner name
blueprints can SetNetAddressable(true), but don't know off the top of my head how you'd name the component as you spawn it
That's for all the leads Zlo, I will try to dig into it a little bit deeper
I'll let you know when I resolve that, thx mate, appreciate your help a lot
what i mean is that my listen server and my client both spawn something, but the client sees what the listen server spawned too
I believe it depends if actor that you are spawning is set to be replicated, and if is it set to be load on client.
If you want to spawn an actor locally, just dont set it to replicate
you mean "Componentn Replicates" under the "Details" Tab from the actor right?
no
that one
@ancient badge I suggest you to watch those yt series, it's short and really well explaining multiplayer basics https://www.youtube.com/watch?v=TEojA3VBXG8
❗ DISCLAIMER: Re-uploaded due to the original video being somehow magically deleted (I didn't do it..) 😭
👋 Welcome to the Replication Series! This series covers how Unreal Engine handles Replication from the ground up starting with what replication is and how Unreal's Client-Server model works and then moves on into more advanced topics.
📹 ...
thanks i looked at the completely wrong section xD
From what I found, it looks like bp can't set net addressable on components :<
to create a component of type, name it as it creates it, attaches it, registers it and sets it net addressable, then returns a pointer to that component
For components created in runtime?
that was for Mleko
Ah, i'm just curious
but yes, blueprint does a terrible job at adding components
Been thinking how you replicate components you have created dynamically
SetIsReplicated(true)
that one is straightforward
making them net addressable without replicating them is better for performance, but also a little bit more complicated
But the creation of the components need to be multicasted/onrep? Or is it handled if I create one on the server
if replicated, only the server needs to make one
and if clients did it as well they would end up with a pair of them
Hello everyone, I have the client run this blueprint, but it doesn't reach the run on server event
Is client owner of this blueprint?
no
I guess that's why it isn't called on the server
You welcome 🙂
if I don't have a default pawn on the game mode, is there a "correct" way to spawn a pawn and possess it so there aren't any network errors? or is this good enough?
Override one of the functions that chooses the pawn
I'm trying to find how to override HandleStartingNewPlayer
All I do is to spawn the pawn but I don't know if I'm supposed to possess it there too
I think that event is a one stop shop, you're basically skipping all the find start spot, choose pawn, etc stuff.
hmmm
I also overrode "FindPlayerStart"
After I did what you suggested, spawned and attached scene comp in c++ and set net addresable and is replicated in code, it finally works 🙂 Really appreciate your help, thanks a lot
few notes
you can do USceneComponent::StaticClass()
you can also do Component->IsA<USceneComponent>() to see if its a scene or derived from it
NULL intensifies
SetNetAddressable() is redundant alongside SetIsReplicated()
const FString ComponentName = "MyScneComponent" + FString::FromInt(Counter);
USceneComponent* NewComponent = NewObject<USceneComponent>(Owner, SceneComponentClass, FName(*ComponentName));
// attach and register
NewComponent->SetNetAddressable():
Counter++;
is how you would do it without making it replicated
not that it hugely matters, just fyi, Counter is a member int32 variable
But it's used by a competent #cpp developer ^^
This is from multiplayer replicated turret. I shoots ray and should check id from player. It always returns null.
This is from controller and it calls beginplay input of that id.
This is from player character
Have you printed PersonalID in characters to make sure they're correct?
Why do you have all these delays
just expose PersonalID on spawn and set it when you spawn the char.
Load -> Spawn -> Possess
yep. input press j -> print personal id ->> prints always correct "username"
I'm wondering how the server RPC is not getting droppped, but you prolly calling it from server, so it's not needed
The turret is not client owned, so you can't call server RPCs from it
Why is that a run on server event
Is the vanilla sessions interface good? I have heard there are some plugins like advanced sessions that improve upon it
Depends on what you need
Yes and yes
Phrased another way then, what do these plugins offer over the vanilla implementation?
More stuff with friends etc, more stuff exposed to BP
Can I say, display a server name, current and max player count, ping, current map, and gamemode with vanilla?
Not sure, have you tried?
You can at least get player counts etc
Hmm alright
Made things little bit more clear. This is from player controller.
that second from third person character BP and it prints correct
This is debug replicated actor only prints players ids and it print only null
so problem is that server doesn't know players ids? only locally players know their?
if I make that "Output Get" replicated in player controller. Then J print doesn't print anything and server neither.
Honestly this is all a bad code structure
Having same property in two different classes, GettingAllActorsOfClass, Running BeginPlay without guarding with authority(you prolly don't need it here), Too many delays
PlayerID is a string too
You got a property already in PlayerState called PlayerId
But PlayerID in this case is username+password because later on database login
And there's where such property should be
Okay!
Still it should be in PlayerState. No reason for it to be all over the place
Okay I try that
How the hell do you even properly replicate Pawn Rotation without a Character Movement
thing just doesn't work
Replication only goes from Server -> Clients.
Input Events (Like your InputAxis Turn Left / Right) only activate on the client.
You need to do a "Run On Server" event to tell the server that you want the rotation changed.
lol I've done that but alright I'll check
Nope
locks in place, doesn't rotate
Multi-cast makes it so only local sees it, rotation on other client is still locked forward
Actor is replicated as well
To start with, are you sure your float is getting to the server fine?
also WTF is that math, why are you getting base aim twice and all that. WHat are you trying to do?
Is actor replicated, has movement replication checked, is component replicated?
wait a second
I can't have movement replication checked because I'm doing a focused heavy physics game
and movement replication causes jitters when hitting into other physics
OK please explain in plain English what you're trying to do here
Then why would anyone else see the thing move? You're not replicating movement or any other variable so why would they see it move?
I'm creating a physics type game. I am not using the normal Character Movement system. There was a way to make physics run better on the server by using fixes by Rama's techniques
I have some amazing news! Massive Update! ~ Feb 21 2016 Using a new algorithm that is a hybrid of both input replication and interpolation, I've now accomplished my goal of a game based on replicating player-controlled physics-simulating characters that can also platform freely! **I can now fully support the network coding for a physics-...
Something similar to this
I have a multiplayer physics game too. What are you trying to do here? Gameplay wise, you're making some star move around?
It's a space game where the player moves in space. Acceleration from boosts, interacting with meteors and what not.
That's exaclty how replicated physics works
but you're not using physics, you're directly updating the rotation.
That's not the problem.
Normal Character Movement with Replicated Movement causes massive jitters with physics interactions (player gliding into a meteor)
and even players going through it
So are you using physics only or physics + CMC or what?
That's not what Rama's approach does
plus unchecking replicated movement, fixes the problem
but then character rotation no longer works
Well his method is of course C++
His method does no direct sets. It's all forces and torques.
You're adding forces then setting transforms all over the place.
And I do such that with my own Ability SYstem, the movement isn't an issue
and fixes
Read over his approach.
- Client runs physics on their end, sends data to server(transform and velocities)
- Server replicates that data out to everyone but that client.
- Other clients add forces to proxies to get them to smoothly match the state from server.
I set ONLY the transfroms in hopes to fix the rotation issue
Which I've been unable to do
Physics replicates fine, matches correctly
I just cannot replicate player rotations
Sure you can, people do it all the time.
For one, ControlRotation isn't gonna be a thing on other clients
I'd back up and start with a super simple proof of concept. Get a cube to fly around and rotate and sync those up.
Add Controller Yaw Input didn't work. Grabbing actor rotation and putting it into a replicated variable didn't work. Replicating Controller Yaw on server/multi-cast didn't work. Setting rotation from said replicated yaw variable didn't work
Sending a transform over certainly would work. You need to send a transform and 2 vectors per frame (your transform, velocity, angular velocity)
Then you replicate those out
then on clients, you smoothly add forces and torques to the physics for all characters but your own
Sending the transform works yeah
as I did show
that's me rotating left
but the actor itself never moves
So for a character
Tick -> LocallyControlled? -> True -> Do Physics -> Send PhysicsState(Run on Server, unreliable)
-> False -> Do Physics Smoothing using PhysicsStateReplicated
SendPhysicsState(Run on Server) -> Set PhysicsStateReplicated(replicated)
Rama's is basically the same setup as the default physcis replication but client-authoritative.
Dig into how the normal physics replication works, there's some heavy math in the smoothing
hi all, I have replicated actors in my game that are weapon pickups. I'd like to rotate them for a visual effect on each client independently, but even with replicate movment off they copy the servers rotation. Is there a way to override this behavior?
im tempted to rotate them on GPU, but wondering if theres something im missing here
Are you sure they're copying the servers and not just doing the same thing because taht's the default?
Again, the physics hasn't been the issue. I replicate them just fine
physics includes rotation
The rotation of pawns is the issue
the movement is jittery like default ue4 movement replication is
ah i think i solved, the root component was set to replicate
it was a mesh which maybe has some logic to auto replicate location or something
lol so Add Controller Yaw Input never replicates
and doing repnotify with input works with setting a transformation
Yeah add controller yaw modifies ControlRotation which is private between client and server as it's a property on the PlayerController. Get base aim does some hackery but yeah the whole ControlRotation setup is janky.
basically I have a credits system in my player state but it's always reading null whenever I get the player state off the owning player
Probably that widget doesn't have an owning player - widgets should never be replicated
i'm not trying to replicate the widget, it's just part of a larger HUD class that gets added to each player's viewport
it adds successfully but it doesn't get the player state off the client, only the server
Probably it just didn't replicate yet then
does player state even replicate? i thought it was just specific to each player
that i add
player state is replicated, the player controller doesn't
Yes
Eventually
Of course you can't rely on PS being replicated at any specific point in time
Might be 2s after level load, 5s...
Is this the local players player state or another clients?
weird, I added a delay of 2 seconds, and it worked, but it read the saved amount of credits from the individual Player State, upon the level loading it's always reading from the initial player's saved amount (being 10 credits)
local player's
unless i shouldn't store credits in the player state since the initial amount it would load in would be replicated across all clients anyways
I'm getting a crash error and I really have no idea where to start. The error is:
Assertion failed: PIEInstanceID != INDEX_NONE [File:D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LazyObjectPtr.cpp] [Line: 22]
It happens after I try and host a listen server via a main menu level and load another. The level loads and the character spawns, but then it instantly freezes and crashes with that error. The map plays fine on its own, is there some extra setup I need to do? This is the code I'm using inside of a button click function to swap maps.
GetWorld()->ServerTravel(URL);```
Credits should be in player state. You just have a race condition.
If I wanted to avoid using default replication for character movement and put all movement data needed for replication into a custom struct, what data would I need to put there?
I have FRepMovement, but the character movement is not as smooth as with normal replication.
I skipped RepRootMotion because I am not using any advanced animations with root motion. Is ReplicatedBasedMovement important? It was always 0s and false from casual debugging.
what if I want to save individual credits amounts between players? if the player state is replicated across both players then it's going to read the same amount basically
unless that's up for me to improve that lol
Everyone has everyone's PlayerState. There's an array of them on Gamestate
mm alright
You just don't have other ppls PlayerController
And may or may not have their pawn depending on relevancy
the players do have their own individual player states when I add the delay of 1 or 2 seconds, I don't get a null player state since I assume it just has enough time to set the player state in, on event construct it's called immediately before clients are assigned a player state, at least I assume
adding the delay of 1 or 2 seconds solved it for me
Of course it could be 3s
Or 20s
yeah, my prof doesn't use a delay at all which is weird lol, which made me think I was doing something wrong
i'm calling it at the exact same time too
yeah since magic numbers are bad lol
Does anyone have a flow chart of what is guaranteed to exist before what else? That would be very handy
that would indeed be very helpful lol
TLDR: nothing
When it comes to networking, I don't think there really is one.
Assume nothing, build everything to withstand null pointers
To the bottom, see if it helps: https://forums.unrealengine.com/t/assertion-failed-pieinstanceid-index-none/563742
I am trying to test in PIE Editor with a Server and Client running to check if i can connect to a Lobby but for some reason Soon as I join the Lobby with the Client the Engine Crashes and Pops this error ^^^^ Any Suggestions Error (Assertion failed: PIEInstanceID != INDEX_NONE [File:D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UO...
I mean there's certain things. I'm pretty sure HUD implies player controller
I don't have any landscapes added though
This isn't multiplayer related
HUD is purely local
For actually replicated classes on client? There's not much that's a sure thing
from what I understand it's Constructor -> PostInitializeComponents -> NativeConstruct but I don't think that helps in this case lol
NativeConstruct is like the BeginPlay of widgets idk
I'm just updating unreal rn, but I'll try it. I already found some things before talking about landscapes and the third person project having this issue, but I am using neither
Nah. I mean how many?
Probably not
In any case, do it, test it, and when your game goes closer to release, anything can be optimized
That's nothing. They're not checking on tick right?
Even if they were checking on ticket probably wouldn't even be a big deal
Hey guys. Asked in UMG already but I wanted to also try here since replication might not be something that the UMG experts would be versed in. I'm trying to replicate changes to a world space widget. I have a simple computer terminal system working pretty well but I want other players to be able to see what the interacting players are typing on the screen. Any ideas about where start looking?
Replicate the text being typed down. OnRep->Show the text to the UMG widget
Ah, rep notify. Rad. Thanks Wiz
If I'm adding a child to a scrollbox will that work the same way or am I gonna have to figure out a way to route a server replicated event through the using player to add said child widget
ScrollBox is part of the UMG widget so it's client only. Every connection would have to do that on his own. So you have to do it OnRep too when that said replicated "action" happens
For example. On "Enter" key is hit you add a scroll box. So you would call a server RPC that sets bHasPressedEnterKey to true and in the OnRep you add the scrollbox to the widget
ok. Yeah right now the way the terminal works is when you hit enter, it commits a string to a new widget which gets added as a child of a scrollbox. Simple chat type stuff. I just didn't think you could do a server RPC from an actor that isn't directly owned by the player, aka a pawn.
This terminal is a separate actor that takes input from the player after the PlayerCharacter BP has input and movement disabled
It's owned by the controller which is owned by the client(player in your terminology). Ownership is checked until you get to the outer most owner
ok. Thanks. I'll work with this. Thanks for pointing me in the right direction
Any tips on working with Steam API? I have to run a build and then share it out to another machine and separate Steam Account every time I want to test something. Is this as good as it gets? lol
You can test on Steam without distributing on Steam right?
Yeah, Standalone works fine for 1 Player - But anything past that I have to build and test on multiple machines.
So in this instance, I'm trying to troubleshoot lobby / leaderboards.
I know, I was specifically asking if there was another way instead of having to run a build and share it out. lol
So I'm guessing no
You can just launch the uproject
if you have engine installed on the machine
That's what I do, it's like 5 seconds from submit to source control to server launching new "build"
server being a shitty laptop
It's mostly the second Steam Account thing, not the actual launching.
Like if I run a dedi + client, it still only uses 1 steam account on the machine, so it kicks the client out of the session.
I'm wondering if I can maybe force the initial server launch to be some kinda universal account, then the client uses my normal steam account.
I'd just make another account, you'll want it for the company/appid anyway
I'm not sure a dedicated server needs an account but IDK for sure
Alright, was trying to see if there's a better way than what I'm doing - Guess there isn't. lol
"Get some friends" 🤣
Okay i'm not much closer to figuring out this error, I'd really appreciate your guys' help
What I have been able to figure out is it only crashes when I have more than 1 game instance open
it provides me with this error Assertion failed: PIEInstanceID != INDEX_NONE [File:D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LazyObjectPtr.cpp] [Line: 22]
For this code const FString URL = "/Game/Maps/MixtapeMansion?Listen"; GetWorld()->ServerTravel(URL);
So this assert triggers when the PIEInstanceID of the second client is not equal to 0, which it wouldn't be
So is it just not possible to test local networking in the editor? I can't imagine this is the case
Something is messing up somewhere, or this is a bug with the engine
Okay also running it standalone works fine, but both clients get connected, I'm guessing i'm misunderstanding something about how this all works xD
Got it working properly now but it still crashes on the client join if I run the instances in viewport instead of standalone
🤷
I FIGURED IT OUT FUCKERS
Okay so anyone having the same issue, go into advanced settings here
Then go down here and make sure "Run Under One Process" is OFF. It is enabled by default.
Idk why I couldn't find anything on this
It's not a really a question, i just want to explain my thoughts about I just want to get the best idea for the make multiplayer implementation of that:, I have an range(oven) actor with the burner and the dial component. So i want to create a timer that when dial is changed and vfx effects to multicast(or onrep(repnotify)) on the time ends up, i'll call multicast function from the server to tell everyone that the time is up on the timer callback.
and while the burner heats, i'll imply the tick functions for heating on the actor's tick method(called on server) so it will evulate and call multicast RPC from the actor
What do clients care about, in terms of the range's state?
float TimeRemaining and bElementIsOn?
or float TimeRemainging and float BurnerTemperature
Clients should care about,
Burner's heat
Dial's degree value
Time that expire,
Overheating,
Burner's VFX
Overheating and VFX can be derived from Heat right?
Heat drives Overheating which drives VFX
Yes
Should I use rep notify ot multicast when the timer is ends up on the server?
How can I get the network insights tab? I'm not really sure where I'm supposed to put the command -NetTrace=1 -tracehost=localhost -trace=net
Either/Or, depends
hi,
probably simple to solve: I've got a basic HUD with the player's points. The points are part of each player's PlayerState, the variable is set to be replicated.
The HUD works fine on the server, but the not on the client.
The point it fails at is when I try to get the other player's playerstate via a function I've put into a general blueprint function library.
What's missing to make it work on the client side too?
kind of solved it. I don't know why yet but setting the own player controller reference on the OnConstruct event does not work reliably.
OnConstruct isn't the place. It's called so early, and also it gets called multiple times. Use OnInitialized. Still you can't be 100% sure it's valid by that time, but it's most of the times, and you can always wait till it's valid
Also this won't work for the simple reason that clients are not aware of other client PlayerControllers
PlayerController is only replicated to owning client
That's why you got PlayerStates. The container that has all PlayerStates is called PlayerArray(it's in GameState)
So meaning that this snippet would never work on clients although it is derived via the Game State?
Meaning, I should never try to get the player state via the controller or vice versa on any client, and instead should just get everything done with the player state directly.
No matter what class is this. Yes this won't work client side
You can always get the PC from PS or vice versa, but you can't get other player's PCs
wowie, that of course changes a lot of things, glad I got to know this early on in this project!
Getting other people PlayerStates is valid though
All this honestly is written in here: #multiplayer message
I've read the bible at least 5x but I fail to reference it for specific things like these / forget the details while developing. Great link nonetheless though
my thinking was just wrong. I thought: hey, although I can't get the PCs directly, I can get them via their PSs right? nope of course not.
Yeah I always keep it by my side when I'm not sure about things xD
the PCs don't just start existing on clients just because I attempt to get to them via the state
that's what I thought was happening lmao
Oh I see where this comes from ^^
Yeah ofc not
yeye...
it's thoughts like these that the Bible doesn't touch on, it's the kind of wishful thinking you get into when nothing works for too long haha
Yeah the bible is by no means a 100% complete source of info, as it would be 1000 pages in that case xD
But yeah it's good that this server exists and that people can ask
great, got it all working now :) fantastic
Only thing that's bothering me right now is that the update of the playerstate is pretty slow even on local machine testing, but that's a whole other story I guess...
alright, got that fixed in splitseconds just by changing the replication settings lol
That's the easy fix yes. Their NetUpdateFrequency is potentially higher than other actors.
In cpp I would use an OnRep_PlayerState.
In BP I would delay until it's valid, or send a signal from the PlayerState class client-side on BeginPlay for example
am having a strange issue where my animation replicates the first time but not the second time (client doesnt replicate)
animation replicates in other parts of my game every single time, so idk, strange, any help will be grateful
what's the difference between #UE_BUILD_SERVER and #WITH_SERVER_CODE?
So, I have an actor that spawns several child actors at BeginPlay and passes a randomized string into each child. The first string is saved and used as a password to log into the parent terminal actor. I print the password so I can see it and display the passwords on the child actors. Problem is, the actual password isn't showing up on any of the children for some reason. Should I be spawning the actors via Server RPC to make sure they are the same for everyone? Does the string randomization have to happen on a server RPC? I'm just trying to figure out why the print string password works but it never shows up on the child actors like its supposed to.
UE_BUILD_SERVER is only true when building a dedicated server. WITH_SERVER_CODE is true for any config that can act as a server - this includes pretty much all configs except Client.
good to know, ty
i need to send some custom options on connect to my server. do i just provide them like a query string?
PC->ConsoleCommand("open 127.0.0.1");
Hello everyone, I am stuck in an issue where the client is able to connect to remote server hosted on windows server. But when I package for the linux build, the is not able to join. I ssh into the server instance and here are the logs.
The connection request is received by the server successfully but I am unable to join. It keeps sending RestartHandshakeRequest. Can anyone help with it?
Does anyone know if its possible to move AI pawns on clients? As in calling "AI Move To"
How can I achieve this?
Function in "player state"
in player controller when beginplay to set that id in player state
It works with dedicated server but when someone else joins game then it set first person id who joined to null
Goal is to have system that players know their unique "MyID = username+password" and server knows everybodys id
server log (I have replicated bp to print all players id from player states)
instead of index 0, try just getting player state and cast to your player state
Which should be eradicated
each player will have their controllers .. so rest of code should work fine
You got a replicated PlayerState variable ready for use in PlayerController class. Learn to use it
Also if you are doing authority stuff in BeginPlay, do them after you do a SwitchHasAuthority and then you don't have to call a server RPC, just a normal event
Read the compendium(in pinned messages) to know what GetPlayerXXX(0) returns when called from different configurations @rocky kestrel
Okay Thank you!
With child actor do you mean child actor component?
If you want an actor to look the same it has to be either replicated and spawned on server or spawned locally and managed well
I'm just using Spawn Actor Of Class. I'm using a Server RPC to spawn the "child" actors. It seems to be spawning them correctly but they aren't showing up in the spawn locations they're supposed to be showing up in.
I'm still not sure what chuld actors really mean? If ChildActorComponent then don't use them as they have so many gotchas and they are bad
Sorry. They are not strictly children
You got a SpawnTransform when you spawn something, make sure it's what it's meant to be, i.e debug
They are just spawned by another actor. So they are independent actors.
Ah ok, great then
ok. Yeah I've been trying to debug the actor spawn transform. I think it might have something to do with the way I'm randomly selecting a location. I'll work on it some more. Thanks
It's just confusing because the random spawn transform was working when I was just doing it all locally. It just started giving me problems when I started running it through a server RPC
Hi, do you need a savegame blueprint if you are planning to use DynamoDB
[noob question] Why does the message only seem to reach the server?
If I put a breakpoint on BeginPlay, it stops on the server & on both clients.
If I put a breakpoint on the sending and receiving end of "Test Event" (image), it stops on both breakpoints on the server, but not on any of the clients on the receiving end.
What have I forgotten(/misunderstood)?
"Multicasts" as they are called only execute properly when on the server. If you want to send a message to everyone from a client you need to make a RPC from a client to the server, then the server can execute a multicast. Here's a nice show off when a RPC does what: https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/RPCs/
It IS sending from the server (as seen in the screenshot where it has stopped on the left breakpoint)...
Is your (I assume?) Actor relevant to all clients?
Also are you sure the actor already exists by that point on all clients when you're calling this?
The actor is placed in the map, and not created on the fly, and there is a 10 sec delay before triggering the event... so it should exist on all clients.
But since it doesn't work, I'm doing something wrong 😆
What do you mean by "relevant to all clients"?
Actors can be relevant or irrelevant based on certain conditions, such as distance or manually messing with things. If they are irrelevant to a certain client they normally don't exist for that client until the actor is relevant again.
Ok. Checking "Replicates" on the blueprint seems to make this message reach the clients. So does it have to be checked in order for events to replicate in actor's blueprint code?
If an actor is not marked as "replicated" or whatever blueprint exactly calls it again it's not networked. If you want something to have a network connection (or not) you need to toggle that yeah.
So it's the "Master switch". 😆
Ok. Then I have a chance to get somewhere with this.
Thanks a million! @twilit radish ❤️
Why is ID on playerstate then, just put it in the PlayerController if you want it to be private between server and owning client
but that's a wacky ass way to do IDs
Just a sanity check, I want to NetSerialize a boolean (and possibly couple more in the future). Is this the correct way to do it?
uint8 Flags = (bProxyIsJumpForceApplied << 0);
Ar.SerializeBits(&Flags, 1);
bProxyIsJumpForceApplied = (Flags & (1 << 0)) ? 1 : 0;
Hey guys! I'm running into an issue executing server event on a client.
as the listening server everything works just as intended:
but on the client
I have replication enabled on the actor as well
server functions don't execute on the client..
@blissful saffron is there a way I can get the client to turn on the lights for the other clients, or is this only possible with the listening server?
Well, you'll need to have your light actor replicate its on/off status to the clients
the client should send to the server, then the server should send out to all clients
how would I go about doing that?
So you could either have a replicated prop that tells whether the light is on or off (the way I'd probably handle it) or you could send a netmulticast rpc from the server once it receives the update
so if your actor replicates, that doesn't mean that every property on the actor is replicated
so maybe set an 'on' variable on your light that is replicated
then when the clients send the server function to turn it on, it sets that variable and that'll replicate back to clients
Do this
Boolean bIsOn(replicated, repnotify)
Client
Input -> Run on server event
Server
Run on Server Event -> Set bIsOn
Everywhere
OnRep_bIsOn -> update stuff (light output, etc, play sound, etc)
^^
https://docs.unrealengine.com/4.27/en-US/Resources/ContentExamples/Networking/1_4/
Learn it, love it
thank you guys for the responses but again sorry for being dumb
Sorry, I can't really see that. What's the issue?
Repnotify my dude
That function
that's where you do light stuff
Inside that function, get LightOn, and select or branch on it
Since it's an overlap and you can do it all with no client input, do this
Server:
Overlap -> HasAuthority? -> Event if you want -> Set w/ notify LightOn
Everyone:
Onrep -> do light stuff by branching or selecting using LightOn
Done.
no RPC events
It's that simple
In your Onrep, that's where you actually modify the lights
That's the end of the chain
This will be like a 3 parter, sec
Make sure the actor is replicated. The light component doesn't have to be.
@dark edge so if I put has authority only the listening server can turn on all the lights
and they replicate down
but if the client touches the button
it doesnt do anything
The overlap will happen on both machines
just the one on the client does nothing
This is all triggered by an overlap correct?
yeah its an overlap
K it should happen on server too
@dark edge what was the point of has authority in the beginning?
if the client interacts with it wouldnt nothing happen?
Without the HasAuthority it might change the light clientside. Repnotify in BP is really just a hack for OnChanged.
It's good practice to gate it
GetWorld() doesn't work in multiplayer?
It should
@dark edge still nothing on clients :( listening server works fine and all the clients see the lights turn on, but if I'm playing as the client and hit 3 only the clients lights turn on :(
You changed your triggering approach
To make it go off of client input you'll need to
Hit 3 -> Run on Server Event
Run On Server Event -> Carry on as normal
Before you were using an overlap, which would happen on the server.
Hitting 3 doesn't happen on the server, so you need to RPC that like how I just diagrammed.
@dark edge interesting so it actually works now
if I call it from 3
but not when I hit the overlap
Simple question : Is this code Secured ? Like I'm having a debate with someone and I keep saying that he shouldn't add inputs to server events as those events are RPC so client can call it and send his own arguments through that so it creates a security issue but he keeps telling me that as long as he doesn't call that RPC from the client it's all good and he's doing that to pass arguments between 2 events on the server. So my question is 1 - Is it secured ? 2 - Can a client call that event (so is it an RPC) through a cheat even if in his blueprint there's no node calling the server from the client ? 🤔
Please ping me if any answer 🙂
@dark edge it works now, I just casted to the character and called an even from there
thank you so much
Hi, dumb question but imagine i pass a Struct in an Server RPC (so from client to server), this struct contains a pointer to an replicated AActor, does the server receive the struct with the AActor client instance or it converts it to the server instance as if i would have passed an AActor* in the rpc instead of the struct
Does the overlap happen on server?
Have you checked that yet?
That can be cheated, I can just call Attack whenever I wanted.
Or rather SRV Attack, I can call that whenever
Even when dead
Because you only do your Not Is Dead check on client
So do we agree when we create a server Events it's an RPC ? And we should never put inputs going from client to server ?
Yes, they're RPCs
Do Server_Attack > Is Not Dead? > continue ....
how would I be able to check for that?
You can put inputs in them
and on client side as you have it
You need to validate actions the server takes that are initiated by the client

)